4

For example, Reductio (for Java/Scala) and QuickCheck (for Haskell). The kind of framework I'm thinking of would provide "generators" for built-in data types and allow the programmer to define new generators. Then, the programmer would define a test method that asserts some property, taking variables of the appropriate types as parameters. The framework then generates a bunch of random data for the parameters, and runs hundreds of tests of that method.

For example, if I implemented a Vector class, and it had an add() method, I might want to check that my addition commutes. So I would write something like (in pseudocode):

boolean testAddCommutes(Vector v1, Vector v2) {
    return v1.add(v2).equals(v2.add(v1));
}

I could run testAddCommutes() on two particular vectors to see if that addition commutes. But instead of writing a few invocations of testAddCommutes, I write a procedure than generates arbitrary Vectors. Given this, the framework can run testAddCommutes on hundreds of different inputs.

Does this ring a bell for anyone?

4 Answers 4

4

There's FsCheck, a port from QuickCheck to F# and thus C#, although most of the doc seems to be for f#. I've been exploring the ideas myself aswell. see : http://kilfour.wordpress.com/2009/08/02/testing-tool-tour-quicknet-preview/

1

I may not understand correctly either, but PEX may be of use to you.

1

to elaborate on my previous remark, the QN code to test the pseudo-code example would look something like this :

new TestRun(1, 1000)
    .AddTransition(new MetaTransition<Input<Vector, Vector>, Vector>
    {
        Name = "Vector Add ",
        Generator = DoubleVectorGenerator,
        Execute = input => input.paramOne.Add(input.paramTwo)
    }
    .RegisterProperty(
        (input, output) =>
            new QnProperty(
                "Is Communative",
                () => QnAssert.IsTrue(output == input.paramTwo.Add(input.paramOne) )
            )
        )
    )
    .Verify()
    .RethrowLastFailureifAny()
    .ReportPropertiesTested(new ConsoleReporter());

where DoubleVectorGenerator is a userdefined class supplying values of the type Input<Vector, Vector>.

-1

I might not understand you correctly but check this out...

http://www.ayende.com/projects/rhino-mocks.aspx

1
  • 1
    Mocking is not what's being asked about
    – Dan Fitch
    Oct 28, 2009 at 21:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.