Continuous Integration + Microsoft Pex = Continuous Exploration
By exploring our code with Microsoft Pex in our continuous integration, we will leverage the full power of automated test generation.
- First let’s deifne what is the Pex in nutshell ?
Pex is a white box testing framework that do the following:
- Generate parameterize unit test if it is not exist
- Run Pex Exploration on parameterize unit test
- Generate unit tests with inputs depend on 2 things
- The code of the method under the test
- The precondition of the test data and parameters in the parameterize unit test (PexAssume)
- Identify if the generated unit tests will success or fail when they run?
- The developer using Pex in his/her day to day development tasks since he/she is working on the Domain or the DAL layer
- The developer start create the parameterize unit test manual and put any precondition as needed (PexAssume, ExpectException, etc.. )
- The developer run Pex Exploration on his/her manual parameterize unit test and see if there is any method generated will fail so he/she start adjust the parameterize unit test by adding PexAssume, ExpectException and so on until all generated test methods become green which indicate that they will pass if they run
- The developer check-in his code (code under test and the manual parameterize unit test) in the source control
- The build start and run Pex Explortion against the manual parameterize unit test and generate the unite tests and see if they has any unit test that fail so the build will fail
pex.exe MyApplication.Tests.dll /nor /ftf
- The developer didn’t use Pex at all, the developer may use Pex for personal check only before check-in his code, the parameterize unit test will not checked-in in the source control
- The developer start develop on the application
- The developer check-in his code in the source control
- The build start and run Pex to generate parameterize unit test
- The build run Pex Explortion against the generated parameterize unit test and generate the unite tests and see if they has any unit test that fail so the build will fail
pex.exe MyApplication.dll /nor /ftf /erm:wizard
All you need to do to integrate Pex with MS Team Build 2010 just invoke the process of the CMD and run Pex from Command line and give it the appropriated parameters