SlideShare une entreprise Scribd logo
1  sur  37
Intro to Testing in Zope, Plone Andriy Mylenkyy © Quintagroup, 2008
What we'll talk about ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Testing intro ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
unittest ,[object Object],[object Object],[object Object]
unittest.py TestSuite  TestCase TC TC TC TestSuite(TS)
unittest: TestCase ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],run(result)  result.startTest() result.stopTest() testMethod() setUp() tearDown() debug
unittest: module members ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
unittest: module members (cont.) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
unittest: TestSuite / TestCase  import unittest as ut class WidgetTC(ut.TestCase): def setUp(self): ... def tearDown(self): ... def testDefaultSize(self): assertEqual(...) def testResize(self): self.failIf(...) def otherTest(self): self.assertRaises(...) if __name__ == '__main__': # 1 # ut.main() #1b# ut.main(defaultTest='WidgetTC') #2,3# suite = ut.TestSuite() # 2 # suite.addTest(ut.makeSuite(WidgetTC)) # 3 # suite.addTest('WidgetTC('otherTest')) #2,3# runner = ut.TextTestRunner() #2,3# runner.run(sute) TestSuite _tests WidgetTC("testDefaultSize") WidgetTC("testResize") unittest.makeSuite(WidgetTC)
unittest: command line mytest.py ---------------------------------------------- import unittest class WidgetTC(unittest.TestCase): ... if __name__ == '__main__': unittest.main() ----------------------------------------------- $ python mytest.py .. OK ------------------------------------------------- $ python mytest.py WidgetTC.testDefaultSize WidgetTC.testResize .. OK ------------------------------------------------- $ python mytest.py -v testDefaultSize (__main__.WidgetTC) ... ok testResize (__main__.WidgetTC) ... ok ... OK
doctest ,[object Object],[object Object]
import types, mymodule, doctest def hasInt(*args): """  Test is integer value present in args. >>> hasInt("the string") False >>> hasInt("the string", 1) True """ args = list(args) while args: if type(args.pop()) == types.IntType: return True return False __test__  = {'My module test' : mymodule, 'My string test' : “””>>>1==1 True“””} if __name__ == '__main__':  doctest.testmod() doctest: bases ,[object Object],[object Object],[object Object],[object Object]
doctest: testmod/testfile ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
doctest: Option flags ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Test ELLIPSIS option >>> range(100)  #doctest:+ELLIPSIS [0, ..., 99] >>> range(100) [0, ..., 99] import doctest “”” >>>  range(100) [0, ..., 99] “”” doctest.testmod( optionflags=doctest.ELLIPSIS)
doctest: Unittest Support ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],“”” >>>  range(100)[0, ..., 99] “”” import doctest, unittest if __name__ == “__main__”: suite = unittest.TestSuite() testrunner = unittest.TextTestRunner() testrunner.run(doctest.DocTestSuite(optionflags=doctest.ELLIPSIS)) # testrunner.run(doctest.DocTestSuite())
doctest: Internal structure object DocTes t Example Example Example result DocTestFinder DocTestRunner
zope.testing ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
zope.testing: Lyaers ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],setUp tearDown setUp tearDown TestCase TestCase TestCase
zope.testing: Lyaers (cont) class  BaseLayer : @classmethod def  setUp (cls): “ Layer setup ” @classmethod def  tearDown (cls): “ Layer teardown ” @classmethod def  testSetUp (cls): “ Before each test setup ” @classmethod def  testTearDown (cls): “ After each test teardown ” class MyTestCase(TestCase): layer = NestedLayer def setUp(self): pass def tearDown(self): pass class NestedLayer( BaseLayer) : @classmethod def  setUp (cls): “ Layer setup ” @classmethod def  tearDown (cls): “ Layer teardown ” testrunner.py --path', directory_with_tests --layer 112 --layer Unit'.split
zope.testing: Levels ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],TestCase TestCase TestCase TestCase TestCase TestCase Level  1 Level  2 TestCase TestCase TestCase Level - 3
zope.testing: Test selection ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
zope.testing: options (cont) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
zope.testing: test.py script ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
zope.testing: examples ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
ZopeTestCase(ZTC) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
ZTC: framework.py vs test.py ,[object Object],[object Object],[object Object],[object Object],[object Object],import os from ZODB.DemoStorage import DemoStorage from ZODB.FileStorage import FileStorage db = os.path.join('..', '..', '..', 'var', 'Data.fs') db = os.path.abspath(db) Storage = DemoStorage(base=FileStorage(db, read_only=1))
ZTC: ZopeTestCase.py ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
ZTC: Entrypoints setUp(self) try: self. beforeSetUp() self.app = self._app() self._setup() self. afterSetUp() except: self._clear() raise tearDown(self) try: self. beforeTearDown() self._clear(1) except: self._clear() raise Before ALL ZTC Folder,  UserFolder,  User, login After  Fixture created   ConnectionRegistry Before delete  folder from self.app After folder delete Before close  connection to ZODB beforeClose() afterClear() After ALL Zope.APP Opens a ZODB connection  Request.__of__(app)
ZTC: Class diagram
ZTC: Writing Tests ,[object Object],[object Object],[object Object],[object Object]
ZTC: Example ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
PortalTestCase ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
PortalTestCase (cont) ,[object Object],setUp(self) try: self. beforeSetUp() self.app = self._app() self.portal = self._portal() self._setup() self. afterSetUp() except: self._clear() raise _portal(self) return self.getPortal() getPortal(self) return getattr(self.app, poratl)
PloneTestCase(PTC) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
PTC: PloneTestCase (cont) ,[object Object],[object Object],[object Object],[object Object],[object Object]
PTC: PloneTestCase example import os, sys if __name__ == '__main__': execfile(os.path.join(sys.path[0], 'framework.py')) from Products.PloneTestCase import PloneTestCase PloneTestCase.setupPloneSite() class TestDocument(PloneTestCase.PloneTestCase): def afterSetUp(self): ... def testAddDocument(self): self.failUnless(...) def test_suite(): ... return suite if __name__ == '__main__': framework()
Resources ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]

Contenu connexe

Tendances

White paper for unit testing using boost
White paper for unit testing using boostWhite paper for unit testing using boost
White paper for unit testing using boostnkkatiyar
 
Perl Testing
Perl TestingPerl Testing
Perl Testinglichtkind
 
Test in action week 2
Test in action   week 2Test in action   week 2
Test in action week 2Yi-Huan Chan
 
Grails/Groovyによる開発事例紹介
Grails/Groovyによる開発事例紹介Grails/Groovyによる開発事例紹介
Grails/Groovyによる開発事例紹介Kiyotaka Oku
 
The Ring programming language version 1.6 book - Part 11 of 189
The Ring programming language version 1.6 book - Part 11 of 189The Ring programming language version 1.6 book - Part 11 of 189
The Ring programming language version 1.6 book - Part 11 of 189Mahmoud Samir Fayed
 
Jdk 7 4-forkjoin
Jdk 7 4-forkjoinJdk 7 4-forkjoin
Jdk 7 4-forkjoinknight1128
 
The Ring programming language version 1.7 book - Part 12 of 196
The Ring programming language version 1.7 book - Part 12 of 196The Ring programming language version 1.7 book - Part 12 of 196
The Ring programming language version 1.7 book - Part 12 of 196Mahmoud Samir Fayed
 
Automated Testing with CMake, CTest and CDash
Automated Testing with CMake, CTest and CDashAutomated Testing with CMake, CTest and CDash
Automated Testing with CMake, CTest and CDashRichard Thomson
 
Selenium with py test by Alexandr Vasyliev for Lohika Odessa Python TechTalks
Selenium with py test by Alexandr Vasyliev for Lohika Odessa Python TechTalksSelenium with py test by Alexandr Vasyliev for Lohika Odessa Python TechTalks
Selenium with py test by Alexandr Vasyliev for Lohika Odessa Python TechTalksLohika_Odessa_TechTalks
 
Clojure - A new Lisp
Clojure - A new LispClojure - A new Lisp
Clojure - A new Lispelliando dias
 
Testing Django Applications
Testing Django ApplicationsTesting Django Applications
Testing Django ApplicationsGareth Rushgrove
 
JavaOne 2015 - Having fun with Javassist
JavaOne 2015 - Having fun with JavassistJavaOne 2015 - Having fun with Javassist
JavaOne 2015 - Having fun with JavassistAnton Arhipov
 
The Ring programming language version 1.8 book - Part 87 of 202
The Ring programming language version 1.8 book - Part 87 of 202The Ring programming language version 1.8 book - Part 87 of 202
The Ring programming language version 1.8 book - Part 87 of 202Mahmoud Samir Fayed
 
Riga Dev Day 2016 - Having fun with Javassist
Riga Dev Day 2016 - Having fun with JavassistRiga Dev Day 2016 - Having fun with Javassist
Riga Dev Day 2016 - Having fun with JavassistAnton Arhipov
 
NIO.2, the I/O API for the future
NIO.2, the I/O API for the futureNIO.2, the I/O API for the future
NIO.2, the I/O API for the futureMasoud Kalali
 

Tendances (20)

White paper for unit testing using boost
White paper for unit testing using boostWhite paper for unit testing using boost
White paper for unit testing using boost
 
JUnit Pioneer
JUnit PioneerJUnit Pioneer
JUnit Pioneer
 
Perl Testing
Perl TestingPerl Testing
Perl Testing
 
Test in action week 2
Test in action   week 2Test in action   week 2
Test in action week 2
 
Grails/Groovyによる開発事例紹介
Grails/Groovyによる開発事例紹介Grails/Groovyによる開発事例紹介
Grails/Groovyによる開発事例紹介
 
The Ring programming language version 1.6 book - Part 11 of 189
The Ring programming language version 1.6 book - Part 11 of 189The Ring programming language version 1.6 book - Part 11 of 189
The Ring programming language version 1.6 book - Part 11 of 189
 
Jdk 7 4-forkjoin
Jdk 7 4-forkjoinJdk 7 4-forkjoin
Jdk 7 4-forkjoin
 
Java custom annotations example
Java custom annotations exampleJava custom annotations example
Java custom annotations example
 
The Ring programming language version 1.7 book - Part 12 of 196
The Ring programming language version 1.7 book - Part 12 of 196The Ring programming language version 1.7 book - Part 12 of 196
The Ring programming language version 1.7 book - Part 12 of 196
 
Phpunit testing
Phpunit testingPhpunit testing
Phpunit testing
 
srgoc
srgocsrgoc
srgoc
 
Automated Testing with CMake, CTest and CDash
Automated Testing with CMake, CTest and CDashAutomated Testing with CMake, CTest and CDash
Automated Testing with CMake, CTest and CDash
 
Selenium with py test by Alexandr Vasyliev for Lohika Odessa Python TechTalks
Selenium with py test by Alexandr Vasyliev for Lohika Odessa Python TechTalksSelenium with py test by Alexandr Vasyliev for Lohika Odessa Python TechTalks
Selenium with py test by Alexandr Vasyliev for Lohika Odessa Python TechTalks
 
Clojure - A new Lisp
Clojure - A new LispClojure - A new Lisp
Clojure - A new Lisp
 
NIO and NIO2
NIO and NIO2NIO and NIO2
NIO and NIO2
 
Testing Django Applications
Testing Django ApplicationsTesting Django Applications
Testing Django Applications
 
JavaOne 2015 - Having fun with Javassist
JavaOne 2015 - Having fun with JavassistJavaOne 2015 - Having fun with Javassist
JavaOne 2015 - Having fun with Javassist
 
The Ring programming language version 1.8 book - Part 87 of 202
The Ring programming language version 1.8 book - Part 87 of 202The Ring programming language version 1.8 book - Part 87 of 202
The Ring programming language version 1.8 book - Part 87 of 202
 
Riga Dev Day 2016 - Having fun with Javassist
Riga Dev Day 2016 - Having fun with JavassistRiga Dev Day 2016 - Having fun with Javassist
Riga Dev Day 2016 - Having fun with Javassist
 
NIO.2, the I/O API for the future
NIO.2, the I/O API for the futureNIO.2, the I/O API for the future
NIO.2, the I/O API for the future
 

Similaire à Zope Testing Guide

Automated Unit Testing
Automated Unit TestingAutomated Unit Testing
Automated Unit TestingMike Lively
 
Practical Glusto Example
Practical Glusto ExamplePractical Glusto Example
Practical Glusto ExampleGluster.org
 
Testing My Patience
Testing My PatienceTesting My Patience
Testing My PatienceAdam Lowry
 
Presto Testing Tools: Benchto & Tempto (Presto Boston Meetup 10062015)
Presto Testing Tools: Benchto & Tempto (Presto Boston Meetup 10062015)Presto Testing Tools: Benchto & Tempto (Presto Boston Meetup 10062015)
Presto Testing Tools: Benchto & Tempto (Presto Boston Meetup 10062015)Matt Fuller
 
Pragmatic unittestingwithj unit
Pragmatic unittestingwithj unitPragmatic unittestingwithj unit
Pragmatic unittestingwithj unitliminescence
 
using python module: doctest
using python module: doctestusing python module: doctest
using python module: doctestmitnk
 
Unit Testing using PHPUnit
Unit Testing using  PHPUnitUnit Testing using  PHPUnit
Unit Testing using PHPUnitvaruntaliyan
 
Php unit the-mostunknownparts
Php unit the-mostunknownpartsPhp unit the-mostunknownparts
Php unit the-mostunknownpartsBastian Feder
 
international PHP2011_Bastian Feder_The most unknown Parts of PHPUnit
international PHP2011_Bastian Feder_The most unknown Parts of PHPUnitinternational PHP2011_Bastian Feder_The most unknown Parts of PHPUnit
international PHP2011_Bastian Feder_The most unknown Parts of PHPUnitsmueller_sandsmedia
 
Android Automated Testing
Android Automated TestingAndroid Automated Testing
Android Automated Testingroisagiv
 
Fighting Fear-Driven-Development With PHPUnit
Fighting Fear-Driven-Development With PHPUnitFighting Fear-Driven-Development With PHPUnit
Fighting Fear-Driven-Development With PHPUnitJames Fuller
 
New Features Of Test Unit 2.x
New Features Of Test Unit 2.xNew Features Of Test Unit 2.x
New Features Of Test Unit 2.xdjberg96
 
Isolated development in python
Isolated development in pythonIsolated development in python
Isolated development in pythonAndrés J. Díaz
 
MT_01_unittest_python.pdf
MT_01_unittest_python.pdfMT_01_unittest_python.pdf
MT_01_unittest_python.pdfHans Jones
 

Similaire à Zope Testing Guide (20)

Automated Unit Testing
Automated Unit TestingAutomated Unit Testing
Automated Unit Testing
 
3 j unit
3 j unit3 j unit
3 j unit
 
Mxunit
MxunitMxunit
Mxunit
 
Practical Glusto Example
Practical Glusto ExamplePractical Glusto Example
Practical Glusto Example
 
Testing My Patience
Testing My PatienceTesting My Patience
Testing My Patience
 
Presto Testing Tools: Benchto & Tempto (Presto Boston Meetup 10062015)
Presto Testing Tools: Benchto & Tempto (Presto Boston Meetup 10062015)Presto Testing Tools: Benchto & Tempto (Presto Boston Meetup 10062015)
Presto Testing Tools: Benchto & Tempto (Presto Boston Meetup 10062015)
 
JUnit 5
JUnit 5JUnit 5
JUnit 5
 
Pragmatic unittestingwithj unit
Pragmatic unittestingwithj unitPragmatic unittestingwithj unit
Pragmatic unittestingwithj unit
 
using python module: doctest
using python module: doctestusing python module: doctest
using python module: doctest
 
Unit Testing using PHPUnit
Unit Testing using  PHPUnitUnit Testing using  PHPUnit
Unit Testing using PHPUnit
 
Php unit the-mostunknownparts
Php unit the-mostunknownpartsPhp unit the-mostunknownparts
Php unit the-mostunknownparts
 
international PHP2011_Bastian Feder_The most unknown Parts of PHPUnit
international PHP2011_Bastian Feder_The most unknown Parts of PHPUnitinternational PHP2011_Bastian Feder_The most unknown Parts of PHPUnit
international PHP2011_Bastian Feder_The most unknown Parts of PHPUnit
 
Android Automated Testing
Android Automated TestingAndroid Automated Testing
Android Automated Testing
 
Fighting Fear-Driven-Development With PHPUnit
Fighting Fear-Driven-Development With PHPUnitFighting Fear-Driven-Development With PHPUnit
Fighting Fear-Driven-Development With PHPUnit
 
New Features Of Test Unit 2.x
New Features Of Test Unit 2.xNew Features Of Test Unit 2.x
New Features Of Test Unit 2.x
 
Scala test
Scala testScala test
Scala test
 
Scala test
Scala testScala test
Scala test
 
Isolated development in python
Isolated development in pythonIsolated development in python
Isolated development in python
 
Junit_.pptx
Junit_.pptxJunit_.pptx
Junit_.pptx
 
MT_01_unittest_python.pdf
MT_01_unittest_python.pdfMT_01_unittest_python.pdf
MT_01_unittest_python.pdf
 

Plus de Quintagroup

Georgian OCDS API
Georgian OCDS APIGeorgian OCDS API
Georgian OCDS APIQuintagroup
 
Open procurement - Auction module
Open procurement - Auction moduleOpen procurement - Auction module
Open procurement - Auction moduleQuintagroup
 
OpenProcurement toolkit
OpenProcurement toolkitOpenProcurement toolkit
OpenProcurement toolkitQuintagroup
 
Open procurement italian
Open procurement italian Open procurement italian
Open procurement italian Quintagroup
 
Plone SEO: Пошукова оптимізація Плон сайтів
Plone SEO: Пошукова оптимізація Плон сайтівPlone SEO: Пошукова оптимізація Плон сайтів
Plone SEO: Пошукова оптимізація Плон сайтівQuintagroup
 
Plone 4. Що нового?
Plone 4. Що нового?Plone 4. Що нового?
Plone 4. Що нового?Quintagroup
 
Calendar for Plone
Calendar for Plone Calendar for Plone
Calendar for Plone Quintagroup
 
Packages, Releases, QGSkel
Packages, Releases, QGSkelPackages, Releases, QGSkel
Packages, Releases, QGSkelQuintagroup
 
Integrator Series: Large files
Integrator Series: Large filesIntegrator Series: Large files
Integrator Series: Large filesQuintagroup
 
Python Evolution
Python EvolutionPython Evolution
Python EvolutionQuintagroup
 
New in Plone 3.3. What to expect from Plone 4
New in Plone 3.3. What to expect from Plone 4New in Plone 3.3. What to expect from Plone 4
New in Plone 3.3. What to expect from Plone 4Quintagroup
 
Overview of Plone-based websites for mobile devices.
Overview of Plone-based websites for mobile devices.Overview of Plone-based websites for mobile devices.
Overview of Plone-based websites for mobile devices.Quintagroup
 
Ecommerce Solutions for Plone
Ecommerce Solutions for PloneEcommerce Solutions for Plone
Ecommerce Solutions for PloneQuintagroup
 
Templating In Buildout
Templating In BuildoutTemplating In Buildout
Templating In BuildoutQuintagroup
 
Releasing and deploying python tools
Releasing and deploying python toolsReleasing and deploying python tools
Releasing and deploying python toolsQuintagroup
 
Zope 3 at Google App Engine
Zope 3 at Google App EngineZope 3 at Google App Engine
Zope 3 at Google App EngineQuintagroup
 
Plone в урядових проектах
Plone в урядових проектахPlone в урядових проектах
Plone в урядових проектахQuintagroup
 

Plus de Quintagroup (20)

Georgian OCDS API
Georgian OCDS APIGeorgian OCDS API
Georgian OCDS API
 
Open procurement - Auction module
Open procurement - Auction moduleOpen procurement - Auction module
Open procurement - Auction module
 
OpenProcurement toolkit
OpenProcurement toolkitOpenProcurement toolkit
OpenProcurement toolkit
 
Open procurement italian
Open procurement italian Open procurement italian
Open procurement italian
 
Plone SEO: Пошукова оптимізація Плон сайтів
Plone SEO: Пошукова оптимізація Плон сайтівPlone SEO: Пошукова оптимізація Плон сайтів
Plone SEO: Пошукова оптимізація Плон сайтів
 
Plone 4. Що нового?
Plone 4. Що нового?Plone 4. Що нового?
Plone 4. Що нового?
 
Calendar for Plone
Calendar for Plone Calendar for Plone
Calendar for Plone
 
Packages, Releases, QGSkel
Packages, Releases, QGSkelPackages, Releases, QGSkel
Packages, Releases, QGSkel
 
Integrator Series: Large files
Integrator Series: Large filesIntegrator Series: Large files
Integrator Series: Large files
 
Python Objects
Python ObjectsPython Objects
Python Objects
 
Python Evolution
Python EvolutionPython Evolution
Python Evolution
 
Screen Player
Screen PlayerScreen Player
Screen Player
 
GNU Screen
GNU ScreenGNU Screen
GNU Screen
 
New in Plone 3.3. What to expect from Plone 4
New in Plone 3.3. What to expect from Plone 4New in Plone 3.3. What to expect from Plone 4
New in Plone 3.3. What to expect from Plone 4
 
Overview of Plone-based websites for mobile devices.
Overview of Plone-based websites for mobile devices.Overview of Plone-based websites for mobile devices.
Overview of Plone-based websites for mobile devices.
 
Ecommerce Solutions for Plone
Ecommerce Solutions for PloneEcommerce Solutions for Plone
Ecommerce Solutions for Plone
 
Templating In Buildout
Templating In BuildoutTemplating In Buildout
Templating In Buildout
 
Releasing and deploying python tools
Releasing and deploying python toolsReleasing and deploying python tools
Releasing and deploying python tools
 
Zope 3 at Google App Engine
Zope 3 at Google App EngineZope 3 at Google App Engine
Zope 3 at Google App Engine
 
Plone в урядових проектах
Plone в урядових проектахPlone в урядових проектах
Plone в урядових проектах
 

Dernier

GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 

Dernier (20)

GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 

Zope Testing Guide

  • 1. Intro to Testing in Zope, Plone Andriy Mylenkyy © Quintagroup, 2008
  • 2.
  • 3.
  • 4.
  • 5. unittest.py TestSuite TestCase TC TC TC TestSuite(TS)
  • 6.
  • 7.
  • 8.
  • 9. unittest: TestSuite / TestCase import unittest as ut class WidgetTC(ut.TestCase): def setUp(self): ... def tearDown(self): ... def testDefaultSize(self): assertEqual(...) def testResize(self): self.failIf(...) def otherTest(self): self.assertRaises(...) if __name__ == '__main__': # 1 # ut.main() #1b# ut.main(defaultTest='WidgetTC') #2,3# suite = ut.TestSuite() # 2 # suite.addTest(ut.makeSuite(WidgetTC)) # 3 # suite.addTest('WidgetTC('otherTest')) #2,3# runner = ut.TextTestRunner() #2,3# runner.run(sute) TestSuite _tests WidgetTC("testDefaultSize") WidgetTC("testResize") unittest.makeSuite(WidgetTC)
  • 10. unittest: command line mytest.py ---------------------------------------------- import unittest class WidgetTC(unittest.TestCase): ... if __name__ == '__main__': unittest.main() ----------------------------------------------- $ python mytest.py .. OK ------------------------------------------------- $ python mytest.py WidgetTC.testDefaultSize WidgetTC.testResize .. OK ------------------------------------------------- $ python mytest.py -v testDefaultSize (__main__.WidgetTC) ... ok testResize (__main__.WidgetTC) ... ok ... OK
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16. doctest: Internal structure object DocTes t Example Example Example result DocTestFinder DocTestRunner
  • 17.
  • 18.
  • 19. zope.testing: Lyaers (cont) class BaseLayer : @classmethod def setUp (cls): “ Layer setup ” @classmethod def tearDown (cls): “ Layer teardown ” @classmethod def testSetUp (cls): “ Before each test setup ” @classmethod def testTearDown (cls): “ After each test teardown ” class MyTestCase(TestCase): layer = NestedLayer def setUp(self): pass def tearDown(self): pass class NestedLayer( BaseLayer) : @classmethod def setUp (cls): “ Layer setup ” @classmethod def tearDown (cls): “ Layer teardown ” testrunner.py --path', directory_with_tests --layer 112 --layer Unit'.split
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28. ZTC: Entrypoints setUp(self) try: self. beforeSetUp() self.app = self._app() self._setup() self. afterSetUp() except: self._clear() raise tearDown(self) try: self. beforeTearDown() self._clear(1) except: self._clear() raise Before ALL ZTC Folder, UserFolder, User, login After Fixture created ConnectionRegistry Before delete folder from self.app After folder delete Before close connection to ZODB beforeClose() afterClear() After ALL Zope.APP Opens a ZODB connection Request.__of__(app)
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36. PTC: PloneTestCase example import os, sys if __name__ == '__main__': execfile(os.path.join(sys.path[0], 'framework.py')) from Products.PloneTestCase import PloneTestCase PloneTestCase.setupPloneSite() class TestDocument(PloneTestCase.PloneTestCase): def afterSetUp(self): ... def testAddDocument(self): self.failUnless(...) def test_suite(): ... return suite if __name__ == '__main__': framework()
  • 37.