Function methodCaller
Call a method using the right data provders
void methodCaller(alias T, U)
(
U func
);
Example
methodCaller should call the method with random numeric values
class TestClass
{
static int usedIntValue = 0;
static ulong usedUlongValue = 0;
void randomMethod(int value, ulong other)
{
usedIntValue = value;
usedUlongValue = other;
}
}
auto instance = new TestClass;
methodCaller!(instance .randomMethod)(&instance .randomMethod);
TestClass .usedIntValue .should .not .equal(0);
TestClass .usedUlongValue .should .not .equal(0);
Example
methodCaller should call the method with custom random generators
class TestClass
{
static int usedIntValue = 0;
static ulong usedUlongValue = 0;
@For!("value", { return 5; }) @For!("other", { return someCustomFunction(); }) void randomMethod(int value,
ulong other)
{
usedIntValue = value;
usedUlongValue = other;
}
}
auto instance = new TestClass;
methodCaller!(instance .randomMethod)(&instance .randomMethod);
TestClass .usedIntValue .should .equal(5);
TestClass .usedUlongValue .should .equal(6);
Example
discoverTestCases should find the same tests like testCases
auto discovery = new TestClassDiscovery;
discovery .addModule!(__FILE__, `trial.discovery.testclass`);
discovery
.discoverTestCases(__FILE__)
.map!(a => a .toString)
.join("\n")
.should .equal(
discovery .getTestCases
.sort!((a, b) => a .location .line < b .location .line)
.map!(a => a .toString)
.join("\n"));