I am trying to use Pex in my project for exploratory testing. However, I cannot get it to run with my existing tests as test seed.
I have successfully used [PexArguments] to provide input testdata. For verification I have now followed the tutorial and implemented the Capitalize function. When I now run Pex, the test case defined in as annotation will be executed. However, the test that is defined in the method, is not executed. I followed the instructions here.
In case it's important: I'm using VisualStudio 2010 and Pex says it's in version 0.94.
Does somebody have an idea what I am doing wrong?
Here's my Test class:
[PexAllowedExceptionFromTypeUnderTest(typeof(InvalidOperationException))]
[PexAllowedExceptionFromTypeUnderTest(typeof(ArgumentException), AcceptExceptionSubtypes = true)]
public partial class Class1Test
{
/// <summary>Test stub for Capitalize(String)</summary>
[PexMethod]
[PexArguments("foo")]
public string Capitalize(string value)
{
string result = Class1.Capitalize(value);
return result;
// TODO: add assertions to method Class1Test.Capitalize(String)
}
[TestMethod]
public void CapitalizeSeed()
{
string result = this.Capitalize("foo2");
Assert.AreEqual("Foo", result);
}
}
Pex will pick up the value from the test method CapitalizeSeed(...) and use it to seed its exploration. It will not execute that TestMethod itself, however. When you run Pex from within Visual Studio, you should be seeing "foo2" reported under the "value" column as one of the inputs. Ddd an assertion in the PexMethod just before the return statement, like so: PexAssert.AreEqual("Foo", result); and you should see the failing testcase.