testing
Provides functionality for unit testing and profiling.
module exceptions
- AssertFailed - Thrown when an assertion failed.
module methods
- assert(comment, value, failMessage) - Basic assert method.
- comment = "" - A comment for the assertion.
- value - A boolean which must be true to satisfy the assertion.
- failMessage = "" - A message which is passed to the AssertFailed class.
- assertTrue(comment, value) - satisfied if value is true.
- comment = "" - A comment for the assertion.
- value - A boolean which must be true to satisfy the assertion.
- assertFalse(comment, value) - satisfied if value is false.
- comment = "" - A comment for the assertion.
- value - A boolean which must be false to satisfy the assertion.
- assertEquals(comment, value1, value2) - satisfied if both values are equal.
- comment = "" - A comment for the assertion.
- value1 - first value.
- value2 - second value.
- assertNotEquals(comment, value1, value2) - satisfied if both values are not equal.
- comment = "" - A comment for the assertion.
- value1 - first value.
- value2 - second value.
- assertNull(comment, value) - satisfied if value is null.
- comment = "" - A comment for the assertion.
- value - The value which must be null.
- assertNotNull(comment, value) - satisfied if value is not null.
- comment = "" - A comment for the assertion.
- value - The value which must not be null.
- assertUndefined(comment, value) - satisfied if value is undefined.
- comment = "" - A comment for the assertion.
- value - The value which must be undefined.
- assertNotUndefined(comment, value) - satisfied if value is not undefined.
- comment = "" - A comment for the assertion.
- value - The value which must not be undefined.
- assertNaN(comment, value) - satisfied if value is not a number.
- comment = "" - A comment for the assertion.
- value - The value which must not be a Number.
- assertNotNaN(comment, value) - satisfied if value is a number.
- comment = "" - A comment for the assertion.
- value - The value which must be a Number.
- fail(comment) - Fails with a comment.
- comment = "" - The comment.
- profile(min, fn) - Measures the time it takes to run a function given as a parameter.
- min = minProfileTime - The minimum time to use for profiling.
- fn - The function to profile. The function wil be called again and again until the min-time is reached.
- returns the time it took to run the function a single time. The time is averaged by the total time/repetitions.
- timeExec(repeat, fn) - Returns the average time used for executing a function. The time is calculated by running the provided function multiple times and messuring the total time for all executions. This is similar to running profile but you specify the repetitions instead of giving a minimum execution time.
- repeat - The number of repetitions of running fn.
- fn - The function to run.
- returns the average time it took to run fn once.
- test(fn) - Runs a Test using a function given and returns the test's report.
- fn - The function to run. Usualy this function would be filled with assert calls.
module classes
- Test(name, testScope) - A basic test task for unit testing.
- Test::run() - Runs the testScope and generates report data.
- Test::report() - Returns a report form the data generated during the test run. Throws an exception if the test could not be run.
- Test::failed = false - States if the testrun failed or not.
- Test::error - The reason why the test run was not successful or undefined.
- Test::startTime - The start time of the test run.
- Test::endTime - The end time of the test run.
- Test::duration - The duration of the test run.
