Your SlideShare is downloading. ×
0
Pruebas en Conceptos básicos y ejemplos
¿qué son y para qué sirven?
 
Unit testing will make you more attractive to the opposite sex.  Martin Aspeli
pruebas unitarias pruebas de integración pruebas funcionales pruebas de sistema
unittest doctest
pruebas unitarias y de integración
base.py from Testing import ZopeTestCase ZopeTestCase.installProduct('My Product') from Products.PloneTestCase.PloneTestCa...
my_test.py import os, sys if __name__ == '__main__': execfile(os.path.join(sys.path[0], 'framework.py')) from base import ...
Instalación de skins y recursos class TestInstallation(MyProductTestCase): """Ensure product is properly in...
Instalación de tipos de contenido class TestInstallation(MyProductTestCase): """Ensure product is properly ...
Instalación de tools y configlets class TestInstallation(MyProductTestCase): """Ensure product is properly ...
Verificando recursos de Kupu class TestInstallation(MyProductTestCase): """Ensure product is properly insta...
Verificando otras propiedades class TestInstallation(MyProductTestCase): """Ensure product is properly inst...
Desinstalación del producto class TestUninstall(MyProductTestCase): """Ensure product is properly uninstall...
Implementación from Interface.Verify import verifyObject from Products.ATContentTypes.interface import IATContentType from...
Creación y edición de contenido class TestContentCreation(MyProductTestCase): """Ensure content type can be...
 
pruebas funcionales y de sistema
zope.testbrowser zope.testrecorder Es elegante y fácil de usar, pero no soporta JavaScript Permite grabar las pruebas en f...
Selenium IDE Selenium Remote Control Selenium Grid
Más información <ul><li>Unit testing framework http ://www.python.org/doc/lib/module-unittest.html </li></ul><ul><li>Test ...
gracias
Upcoming SlideShare
Loading in...5
×

Pruebas en Plone: conceptos básicos y ejemplos

879

Published on

Charla sobre pruebas en Plone para la reunión de noviembre de 2009 del Grupo de Usuarios de Plone en México. (12/11/2009)

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
879
On Slideshare
0
From Embeds
0
Number of Embeds
8
Actions
Shares
0
Downloads
20
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide
  • Transcript of "Pruebas en Plone: conceptos básicos y ejemplos"

    1. 1. Pruebas en Conceptos básicos y ejemplos
    2. 2. ¿qué son y para qué sirven?
    3. 4. Unit testing will make you more attractive to the opposite sex. Martin Aspeli
    4. 5. pruebas unitarias pruebas de integración pruebas funcionales pruebas de sistema
    5. 6. unittest doctest
    6. 7. pruebas unitarias y de integración
    7. 8. base.py from Testing import ZopeTestCase ZopeTestCase.installProduct('My Product') from Products.PloneTestCase.PloneTestCase import PloneTestCase from Products.PloneTestCase.PloneTestCase import FunctionalTestCase from Products.PloneTestCase.PloneTestCase import setupPloneSite setupPloneSite(products=['My Product']) class MyProductTestCase(PloneTestCase): &quot;&quot;&quot;We use this base class for all the tests in this package. If necessary, we can put common utility or setup code in here. This applies to unit test cases. &quot;&quot;&quot; class MyProductFunctionalTestCase(FunctionalTestCase): &quot;&quot;&quot;We use this class for functional integration tests that use doctest syntax. Again, we can put basic common utility or setup code in here. &quot;&quot;&quot;
    8. 9. my_test.py import os, sys if __name__ == '__main__': execfile(os.path.join(sys.path[0], 'framework.py')) from base import MyProductTestCase class TestClass(MyProductTestCase): &quot;&quot;&quot;Tests for this and that...&quot;&quot;&quot; ... def test_suite(): from unittest import TestSuite, makeSuite suite = TestSuite() ... suite.addTest(makeSuite(TestClass)) ... return suite if __name__ == '__main__': framework()
    9. 10. Instalación de skins y recursos class TestInstallation(MyProductTestCase): &quot;&quot;&quot;Ensure product is properly installed&quot;&quot;&quot; def afterSetUp(self): ... self.skins = self.portal.portal_skins self.csstool = self.portal.portal_css self.jstool = self.portal.portal_javascripts ... def testSkinLayersInstalled(self): &quot;&quot;&quot;Verifies the skin layer was registered&quot;&quot;&quot; self.failUnless('my_product_skin' in self.skins.objectIds()) def testCssInstalled(self): &quot;&quot;&quot;Verifies the associated CSS file was registered&quot;&quot;&quot; stylesheetids = self.csstool.getResourceIds() self.failUnless('my_css_id' in stylesheetids) def testJavascriptsInstalled(self): &quot;&quot;&quot;Verifies the associated JavaScript file was registered&quot;&quot;&quot; javascriptids = self.jstool.getResourceIds() self.failUnless('my_js_id' in javascriptids)
    10. 11. Instalación de tipos de contenido class TestInstallation(MyProductTestCase): &quot;&quot;&quot;Ensure product is properly installed&quot;&quot;&quot; def afterSetUp(self): ... self.types = self.portal.portal_types self.factory = self.portal.portal_factory ... def testTypesInstalled(self): &quot;&quot;&quot;Verifies the content type was installed&quot;&quot;&quot; self.failUnless('My Type' in self.types.objectIds()) def testPortalFactorySetup(self): &quot;&quot;&quot;Verifies the content type was registered in the portal factory. The portal factory ensures that new objects are created in a well-behaved fashion. &quot;&quot;&quot; self.failUnless('My Type' in self.factory.getFactoryTypes())
    11. 12. Instalación de tools y configlets class TestInstallation(MyProductTestCase): &quot;&quot;&quot;Ensure product is properly installed&quot;&quot;&quot; def afterSetUp(self): ... self.config = self.portal.portal_controlpanel ... def testToolInstalled(self): &quot;&quot;&quot;Verifies a tool was installed&quot;&quot;&quot; self.failUnless(getattr(self.portal, 'my_tool', None) is not None) def testConfigletInstalled(self): &quot;&quot;&quot;Verifies a configlet was installed&quot;&quot;&quot; configlets = list(self.config.listActions()) self.failUnless('my_configlet_id' in configlets)
    12. 13. Verificando recursos de Kupu class TestInstallation(MyProductTestCase): &quot;&quot;&quot;Ensure product is properly installed&quot;&quot;&quot; def afterSetUp(self): ... self.kupu = self.portal.kupu_library_tool ... def testKupuResourcesSetup(self): &quot;&quot;&quot;Verifies the content type can be linked inside Kupu&quot;&quot;&quot; linkable = self.kupu.getPortalTypesForResourceType('linkable') self.failUnless('My Type' in linkable)
    13. 14. Verificando otras propiedades class TestInstallation(MyProductTestCase): &quot;&quot;&quot;Ensure product is properly installed&quot;&quot;&quot; def afterSetUp(self): ... self.props = self.portal.portal_properties ... def testDefaultPageTypes(self): &quot;&quot;&quot;Verifies the content type can be used as the default page in a container object like a folder. &quot;&quot;&quot; self.failUnless('My Type' in self.props.site_properties.getProperty('default_page_types'))
    14. 15. Desinstalación del producto class TestUninstall(MyProductTestCase): &quot;&quot;&quot;Ensure product is properly uninstalled&quot;&quot;&quot; def afterSetUp(self): ... self.qitool = self.portal.portal_quickinstaller self.qitool.uninstallProducts(products=['My Product']) ... def testProductUninstalled(self): &quot;&quot;&quot;Verifies the product was uninstalled&quot;&quot;&quot; self.failIf(self.qitool.isProductInstalled('My Product'))
    15. 16. Implementación from Interface.Verify import verifyObject from Products.ATContentTypes.interface import IATContentType from Products.MyProduct.interfaces import IMyProduct class TestContentType(MyProductTestCase): &quot;&quot;&quot;Ensure content type implementation&quot;&quot;&quot; def afterSetUp(self): self.folder.invokeFactory('My Type', 'mytype1') self.mytype1 = getattr(self.folder, 'mytype1') def testImplementsATContentType(self): &quot;&quot;&quot;Verifies the object implements the base Archetypes interface&quot;&quot;&quot; iface = IATContentType self.failUnless(iface.providedBy(self.mytype1)) self.failUnless(verifyObject(iface, self.mytype1)) def testImplementsMyType(self): &quot;&quot;&quot;Verifies the object implements the content type interface&quot;&quot;&quot; iface = IMyType self.failUnless(iface.providedBy(self.mytype1)) self.failUnless(verifyObject(iface, self.mytype1))
    16. 17. Creación y edición de contenido class TestContentCreation(MyProductTestCase): &quot;&quot;&quot;Ensure content type can be created and edited&quot;&quot;&quot; def afterSetUp(self): self.folder.invokeFactory('My Type', 'mytype1') self.mytype1 = getattr(self.folder, 'mytype1') def testCreateMyType(self): &quot;&quot;&quot;Verifies the object has been created&quot;&quot;&quot; self.failUnless('mytype1' in self.folder.objectIds()) def testEditMyType(self): &quot;&quot;&quot;Verifies the object can be properly edited&quot;&quot;&quot; self.mytype1.setTitle('A title') self.mytype1.setDescription('A description') ... self.assertEqual(self.mytype1.Title(), 'A title') self.assertEqual(self.mytype1.Description(), 'A description') ...
    17. 19. pruebas funcionales y de sistema
    18. 20. zope.testbrowser zope.testrecorder Es elegante y fácil de usar, pero no soporta JavaScript Permite grabar las pruebas en formato zope.testbrowser o Selenium
    19. 21. Selenium IDE Selenium Remote Control Selenium Grid
    20. 22. Más información <ul><li>Unit testing framework http ://www.python.org/doc/lib/module-unittest.html </li></ul><ul><li>Test interactive Python examples http://www.python.org/doc/lib/module-doctest.html </li></ul><ul><li>Dive into Python de Mark Pilgrim http ://diveintopython.org/unit_testing/ </li></ul><ul><li>Testing in Plone de Martin Aspeli http://plone.org/documentation/tutorial/testing </li></ul><ul><li>Selenium web application testing system http://selenium.seleniumhq.org/ </li></ul>
    21. 23. gracias
    1. A particular slide catching your eye?

      Clipping is a handy way to collect important slides you want to go back to later.

    ×