Test Case

All top, describe, context, and it, are test cases that encapsulates sets of tests and other test casess. If the code evaluates without an error, or the error is listed as an expected error, then the report will have a line for the test case that has an initial “ok”. If something fails it will read “not ok” and all reports will possibly be exposed. There will also be a description of the failing test case, which typically will include its type and description.

The call world should only be used if several modules are tested at once in a superworld, and likewise the call context should only be used for adding context.

The description will if necessary call require with the testee as argument. This will then become the top of the subject stack. The context and it will not set subject.

Call to description will set a temporal value as the return value from the tester. This value is not used if the tester makes a normal return value. The context and it will not set the temporal value.

Because a thrown error is sufficient to create a report from the test case itself it is possible to use assert for simple testing.

Spies will set up expected behavior in the test case. The spies carp and croak creates a short message, cluck and confess creates a long message with a backtrace, carp and cluck continues running the tests, while croak and confess terminates the current test case. All of them injects a report.

Test cases can have registered data extractors, which will extract data from the description and injects the extracted data into the attached function.

The descriptions can have replacement messages on a subpage named by the language code. That page would be a single table with mapping from one string to another, possibly with embedded patterns. That will make it possible to write a description in English for common testing, and then localize the string into some other language.

generated by LDoc 1.4.6