Opened 11 years ago

#191 new enhancement

data generator / test support library

Reported by: Anya Helene Bagge Owned by: magne
Priority: medium Milestone: m13.10
Component: magnolia-eclipse Version:
Keywords: Cc:
Blocked By: Blocking:

Description

We need a library for data generation and test reporting.

The data generator should probably be called like this:

value = generate<type>(random, options);

or

type value;
generate(value, random, options);

And it should be able to provide a mix of preselected and random values. The "options" might be used to tune the generator (i.e., "I need another value equal to this").

A test would look something like this:

void test_foo(Random& random, TestState& state) {
  TestState myState = state.newTest("foo");
  for(int i = 0; i < myState.iterations(); i++) {
    myState.start(i);
    T v1 = generate<T>(random, myState.options());
    // store value so it can be printed
    // or – store state of generator instead
    myState.value(0, v1);
    U v2 = generate<U>(random, myState.options());
    myState.value(1, v2);
    try {
      axiom_foo(v1, v2);
      myState.ok();
    }
    catch(AssertionFailed e) {
      myState.failed(e);
    }
    // plus a case for not tested due to preconditions?

    myState.done();
  }
  // deleting myState should store relevant results in state
}

The tests can be generated by the meta system once the support libraries are in place.

Change History (0)

Note: See TracTickets for help on using tickets.