Pruebas en Plone

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

0 comments

Post a comment

    Post a comment
    Embed Video
    Edit your comment Cancel

    1 Favorite

    Pruebas en Plone - Presentation Transcript

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

    + Héctor VelardeHéctor Velarde, 2 years ago

    custom

    441 views, 1 favs, 0 embeds more stats

    Conceptos básicos y ejemplos

    More info about this document

    CC Attribution-NonCommercial-ShareAlike LicenseCC Attribution-NonCommercial-ShareAlike LicenseCC Attribution-NonCommercial-ShareAlike License

    Go to text version

    • Total Views 441
      • 441 on SlideShare
      • 0 from embeds
    • Comments 0
    • Favorites 1
    • Downloads 8
    Most viewed embeds

    more

    All embeds

    less

    Flagged as inappropriate Flag as inappropriate
    Flag as inappropriate

    Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

    Cancel
    File a copyright complaint
    Having problems? Go to our helpdesk?

    Categories