Microsoft Code Digger
channel9.msdn.com
channel9.msdn.com
[1] : http://www.evosuite.org
http://groups.csail.mit.edu/pag/daikon/download/doc/daikon.p...
That's not true.
public static void TestWrapper(String foo, Int32 bar, Boolean buzz, Decimal foobar)
{
var thing = new Thing(foo, bar);
thing.Buzz = buzz;
Test(thing, blah);
}
public static Test(Thing thing, Decimal foobar)
{
thing.DoStuff();
if (thing.State == 42)
{
thing.DoOtherStuff(foobar);
}
}
In my experience Pex yields really great results when you use it to analyze methods that are close to mathematically functions with not to many side effects and especially state mutation. Tracking changing state over time and finding sequences of operations to prepare an object to a certain state and then checking the behavior of the object in this state is much harder than analyzing a (almost) pure function. using System;
using System.Text.RegularExpressions;
public class Program
{
public static String Puzzle(String input)
{
if (new Regex("123(foo|bar){3}456[0-9]{5}789").IsMatch(input))
{
throw new ArgumentException();
}
else
{
return input;
}
}
}
Pex reported three test cases. null ArgumentNullException
"" okay
"123foobarbar45600000789bb" ArgumentException
Try this example yourself.http://www.pexforfun.com/default.aspx?language=CSharp&co...
UPDATE: I was wrong - Rex was integrated into Pex in 2010 and this made Pex much smarter when it has to deal with regular expressions.
Am I misunderstanding, or is this akin to QuickCheck for C#?
[1] http://www.cse.chalmers.se/~rjmh/QuickCheck/manual.html [2] http://research.microsoft.com/en-us/projects/pex/ [3] http://research.microsoft.com/en-us/projects/z3m/ [4] http://www.pexforfun.com/
// What values of v and i can cause an exception? Ask Pex to find out!
public static void Puzzle(int[] v, int i)
{
if (v[i + 2] + 5 == v.Length + i)
throw new Exception("hidden bug!");
}
and then it automatically finds the breaking input: {-6} -2 Exception hidden bug!