TestClassDiscovery should find the Test Suite class
auto discovery = new TestClassDiscovery(); discovery.addModule!(`lifecycle/trial/discovery/testclass.d`, `trial.discovery.testclass`); auto testCases = discovery.getTestCases; testCases.length.should.equal(2); testCases[0].suiteName.should.equal(`trial.discovery.testclass.SomeTestSuite`); testCases[0].name.should.equal(`A simple test`); testCases[1].suiteName.should.equal(`trial.discovery.testclass.OtherTestSuite`); testCases[1].name.should.equal(`Some other name`);
discoverTestCases should find the Test Suite class
auto testDiscovery = new TestClassDiscovery; auto testCases = testDiscovery.discoverTestCases(__FILE__); testCases.length.should.equal(2); testCases[0].suiteName.should.equal(`trial.discovery.testclass.SomeTestSuite`); testCases[0].name.should.equal(`A simple test`); testCases[1].suiteName.should.equal(`trial.discovery.testclass.OtherTestSuite`); testCases[1].name.should.equal(`Some other name`);
TestClassDiscovery should execute tests from a Test Suite class
scope (exit) { SomeTestSuite.lastTest = ""; } auto discovery = new TestClassDiscovery(); discovery.addModule!(`lifecycle/trial/discovery/testclass.d`, `trial.discovery.testclass`); auto test = discovery.getTestCases.filter!(a => a.suiteName == `trial.discovery.testclass.SomeTestSuite`) .filter!(a => a.name == `A simple test`).front; test.func(); SomeTestSuite.lastTest.should.equal("a simple test");
TestClassDiscovery should execute the before and after methods tests from a Test Suite class
scope (exit) { OtherTestSuite.order = []; } auto discovery = new TestClassDiscovery(); discovery.addModule!(`lifecycle/trial/discovery/testclass.d`, `trial.discovery.testclass`); auto test = discovery.getTestCases.filter!(a => a.suiteName == `trial.discovery.testclass.OtherTestSuite`) .filter!(a => a.name == `Some other name`).front; test.func(); OtherTestSuite.order.should.equal(["before all", "before each", "a custom test", "after each", "after all"]);