locked
Pex and Test Project Generations RRS feed

  • Question

  • One of the things I’ve run into when I’m using Pex in VS that’s kind of annoying is when it tries to generate a test project. Let’s say I have a project called StringParsing, and I already have a test project called StringParsing.Tests. If I run Pex on a method in StringParsing and a boundary condition is hit (e.g. time limit), Pex gives me the dialog on how to fix it, but when it tries to generate the test project, it defaults to “StringParsing1.Tests” and there’s no way for me to change it. It would be nice if the dialog window gave the user the ability to name the test project whatever s/he wants, like “StringParsing.Tests.Pex”. Is there a way to get around this, or can this be changed in the future?

    Monday, September 14, 2009 1:02 PM

Answers

  • The next version of Pex (0.16) will give you the opportunity to rename the generated test project.
    Jonathan "Peli" de Halleux
    Tuesday, September 15, 2009 11:54 AM

All replies

  • Indeed, a number of things could be improved there. Let me explain what happens:

     - when starting, Pex looks for a test project associated to the project you are trying to 'Pex'. It looks for projects that (1) reference the project under test, (2) reference Microsoft.Pex.Framework (3) and have the PexAssemblyUnderTestAttribute attribute pointing to the project under test (i.e. [assembly: PexAssemblyUnderTest("StringLibrary")]). When all conditions are found, Pex automatically picks this test project to save the data.

     - when Pex does not find a test project, it generates new parameterized unit tests in an in-memory assembly. By default, it adds tries to find a unique project name by appending '.Tests' + numbers. This is where the SringLibrary1.Tests comes from.

     - when the generated tests or other events come back from Pex into Visual Studio, each of them has a metadata location, i.e. a project, a type, a method etc... The addin uses this information to insert the generated test cases or apply the fixes etc. Therefore, because we picked the name StringLibrary1.Tests - this is where all those event will come from Pex and that is why you cannot change it for now.

    I understand that the situation is not great right now so we will  try to do somethign about this in the next or +2 version of Pex. Meanwhile, make sure to 'bind' your test project by adding a [assembly: PexAssemblyUnderTest] attribute.

    (keeping this thread open until resolved).


    Jonathan "Peli" de Halleux
    Monday, September 14, 2009 3:38 PM
  • The next version of Pex (0.16) will give you the opportunity to rename the generated test project.
    Jonathan "Peli" de Halleux
    Tuesday, September 15, 2009 11:54 AM
  • Thanks, Peli.
    Tuesday, September 15, 2009 12:02 PM
  • What about this blog post on Pex? ;)
    Jonathan "Peli" de Halleux
    Tuesday, September 15, 2009 12:21 PM