locked
Allow excpetion RRS feed

  • Question

  • hello pex team,

    when we pex our code, and a test case table is shown, there will be a "allow exception" button.
    so what does that mean ? allow exception, for what ?
    Monday, October 26, 2009 5:19 PM

Answers

  • This is a feature that makes it easy to concentrate on "positive test cases" when generating data with Pex:
    If you don't want to specify exactly under which conditions it is okay for the product code to throw a particular exception, then you can tell Pex that an exception type "is allowed". Then generated test cases throwing that exception will be marked as "passing", and not "failing".

    The button in Visual Studio will add an [PexAllowedException(...)] annotation to your parameterized unit tests.

    You can move the attribute up to the class level, to allow the exception for all parameterized unit tests in that class, and you can even move it to the (test) assembly level.
    The attribute has a few parameters to further define where this exception is okay.

    Later, you can write special (parameterized) unit tests to explicitly define the conditions under which the exception must be thrown.

    Nikolai Tillmann - Tell us how you use Pex
    Tuesday, October 27, 2009 2:51 AM

All replies

  • This is a feature that makes it easy to concentrate on "positive test cases" when generating data with Pex:
    If you don't want to specify exactly under which conditions it is okay for the product code to throw a particular exception, then you can tell Pex that an exception type "is allowed". Then generated test cases throwing that exception will be marked as "passing", and not "failing".

    The button in Visual Studio will add an [PexAllowedException(...)] annotation to your parameterized unit tests.

    You can move the attribute up to the class level, to allow the exception for all parameterized unit tests in that class, and you can even move it to the (test) assembly level.
    The attribute has a few parameters to further define where this exception is okay.

    Later, you can write special (parameterized) unit tests to explicitly define the conditions under which the exception must be thrown.

    Nikolai Tillmann - Tell us how you use Pex
    Tuesday, October 27, 2009 2:51 AM
  • Thanks Nikalai :)
    Tuesday, October 27, 2009 7:32 AM