TestSuite - acadet/oscar GitHub Wiki

TestSuite class collects your tests, runs them and creates you a sum up.

In brief

var suite : TestSuite;

suite = new TestSuite();
suite.add(new A()).add(new B()); // Add your test classes
suite.run(TestSuiteOutput.HTML); // Here we go!

References

Run options

public void run(output? : TestSuiteOutput, maxRuntime? : number, buildFailure? : number)

When launching your suite, you can provide different options:

  • output: Desired output (CONSOLE - default or HTML).
  • maxRuntime: Sets maximum runtime allowed for async tests (default 30s). See section below for more details.
  • buildFailure: If output is CONSOLE, you can specify process will exit with a failure code if at least a single test has failed. See Continuous Integration sub-section below.

Outputs

Oscar is able to generate a whole HTML page wrapping a unit testing sum up. At a glance, you know what is going on :wink:

Otherwise, it could be sometimes better to have a console output (especially on a server). No worries, Oscar can deal with it too!

Maximum runtime

When running an asynchronous test, a timer starts simultaneously. At the end of its period, if no notifications have been received from this test, Oscar aborts it and considers this guy as failed. maxRuntime sets this period in milliseconds.

Continuous Integration

This paragraph is for badass developers. If you are using continuous integration solutions such as Travis, you might be interested in running your tests each build. In particular, you would like to consider a build as failed if some tests are.

Therefore, Oscar is able to exit nodejs runner with a failure code (exit(1)) to set the state of your build.

Wanna more? Alright, maybe auto-launchering feature could arouse your hunger :wink:!

Notes

  • Only a single test is active, Oscar does not run them in parallel. This process avoids conflicts when using static vars. Besides, runtime timer prevents deadlocks.
  • Oscar shuffles your test suite when running it. Then, you can avoid inattention coding. If outcome is different for two suites, you should check how you are using static variables!