Function selectTests

Selects the tests matching the run arguments

const(TestCase)[] selectTests(
  const(TestCase)[] tests,
  RunArguments arguments
);

Example

selectTests returns both tests "a.b first" and "a.c second" for empty arguments

const(TestCase)[] tests = [
  TestCase("a.b", "first", &TestMock),
  TestCase("a.c", "second", &TestMock)
];

selectTests(tests, RunArguments()).fullNames.should.equal(["a.b first", "a.c second"]);

Example

selectTests returns only "a.b some test" for the test name filter "=some test"

const(TestCase)[] tests = [
  TestCase("a.b", "some test", &TestMock),
  TestCase("a.b", "some test extra", &TestMock),
  TestCase("a.c", "other", &TestMock)
];

RunArguments arguments;
arguments.testName = "=some test";

selectTests(tests, arguments).fullNames.should.equal(["a.b some test"]);

Example

selectTests returns only "a.c some test" for the suite filter "=a.c" and the test name filter "some"

const(TestCase)[] tests = [
  TestCase("a.b", "some test", &TestMock),
  TestCase("a.c", "some test", &TestMock),
  TestCase("a.cd", "other", &TestMock)
];

RunArguments arguments;
arguments.suiteName = "=a.c";
arguments.testName = "some";

selectTests(tests, arguments).fullNames.should.equal(["a.c some test"]);

Example

selectTests returns only "a.b some test" for the full name filter "=a.b some test"

const(TestCase)[] tests = [
  TestCase("a.b", "some test", &TestMock),
  TestCase("a.b", "some test extra", &TestMock),
  TestCase("a.c", "some test", &TestMock)
];

RunArguments arguments;
arguments.fullName = "=a.b some test";

selectTests(tests, arguments).fullNames.should.equal(["a.b some test"]);

Example

selectTests returns only "a.b first" for the location at line 15 of a file with tests at lines 10 and 20

auto first = TestCase("a.b", "first", &TestMock);
first.location = SourceLocation("source/a/b.d", 10);

auto second = TestCase("a.b", "second", &TestMock);
second.location = SourceLocation("source/a/b.d", 20);

const(TestCase)[] tests = [first, second];

RunArguments arguments;
arguments.at = "a/b.d:15";

selectTests(tests, arguments).fullNames.should.equal(["a.b first"]);