Tuesday, June 14, 2011

Pex and unit testing

Everyone says that Pex generates unit tests. I am not sure if it holds. Pex knows what does your code do, but it definitely does not know what it should do.


Still I see three situations Pex can be really useful with.


  • It can report you exceptions caused by inputs you have not thought of.

  • When your code coverage is lower than you would expect, you may use Pex to see what paths you have not considered.

  • When you want to refactor a component that is not covered with unit tests, you can use unit tests generated by Pex to ensure you do not break the original functionality.