Function parseString

string parseString (
  string someString
);

Example

resolve the string tokens

`"string token"`.parseString.should.equal("string token");
`"string \" token"`.parseString.should.equal("string \" token");
"`string token`".parseString.should.equal("string token");

Example

getTestCases should find the spec suite

auto specDiscovery = new SpecTestDiscovery;
auto tests = specDiscovery.getTestCases.filter!(
    a => a.suiteName == "trial.discovery.spec.Algorithm").array;

tests.length.should.equal(1).because("the Spec suite defined is in this file");
tests[0].name.should.equal("should return false when the value is not present");

Example

discoverTestCases should find the spec suite

auto specDiscovery = new SpecTestDiscovery;
auto tests = specDiscovery.discoverTestCases(__FILE__).filter!(
    a => a.suiteName == "trial.discovery.spec.Algorithm").array;

tests.length.should.equal(1).because("the Spec suite defined is in this file");
tests[0].name.should.equal("should return false when the value is not present");

Example

getTestCases should find the spec suite

auto specDiscovery = new SpecTestDiscovery;
auto tests = specDiscovery.getTestCases.filter!(
    a => a.suiteName == "trial.discovery.spec.Algorithm").array;

tests.length.should.equal(1).because("the Spec suite defined is in this file");
tests[0].name.should.equal("should return false when the value is not present");

Example

getTestCases should find nested spec suites

auto specDiscovery = new SpecTestDiscovery;
auto suites = specDiscovery.getTestCases.map!(a => a.suiteName).array;

suites.should.contain(["trial.discovery.spec.Nested describes.level 1.level 2",
    "trial.discovery.spec.Nested describes.other level 1.level 2"]).because(
    "the Spec suites are defined in this file");

Example

It should execute the spec before all hooks

auto specDiscovery = new SpecTestDiscovery;
auto tests = specDiscovery.getTestCases.filter!(
    a => a.suiteName.startsWith("trial.discovery.spec.Before all")).array;

trace = "";
tests[0].func();
tests[1].func();

trace.should.equal("before1 before2 test1 test2");

trace = "";
tests[2].func();

trace.should.equal("before2-bis test3");

Example

It should execute the spec after all hooks

auto specDiscovery = new SpecTestDiscovery;
auto tests = specDiscovery.getTestCases.filter!(
    a => a.suiteName.startsWith("trial.discovery.spec.After all")).array;

trace = "";
tests[0].func();
tests[1].func();

trace.should.equal("test1 test2 after2 after1");

trace = "";
tests[2].func();

trace.should.equal("test3 after2-bis");

Example

It should execute the spec before hooks

auto specDiscovery = new SpecTestDiscovery;
auto tests = specDiscovery.getTestCases.filter!(
    a => a.suiteName.startsWith("trial.discovery.spec.Before each")).array;

trace = "";
tests[0].func();
tests[1].func();

trace.should.equal("before1 test1 before1 before2 test2 ");

trace = "";
tests[2].func();

trace.should.equal("before1 before2-bis test3");

Example

It should execute the spec after hooks

auto specDiscovery = new SpecTestDiscovery;
auto tests = specDiscovery.getTestCases.filter!(
    a => a.suiteName.startsWith("trial.discovery.spec.After each")).array;

trace = "";
tests[0].func();
tests[1].func();

trace.should.equal("test1 after1 test2 after2 after1");

trace = "";
tests[2].func();

trace.should.equal("test3 after2-bis after1");

Example

discoverTestCases should find the same tests like testCases

auto testDiscovery = new SpecTestDiscovery;

testDiscovery
  .discoverTestCases(__FILE__).map!(a => a.toString).join("\n")
    .should.equal(
      testDiscovery.getTestCases
      .filter!(a => a.location.fileName.canFind(__FILE__))
      .map!(a => a.toString).join("\n"));