ES-Test allows the developer to write and execute Unit Test classes (code segments that test units of functionality of the underlying system). In order to write a unit test, the root class of your system must inherit from ES_TEST. The following figure shows the generic syntax of such class.
There are three types of Test Cases:
· Boolean test case: returns a Boolean value as the result of a test on the system under study. This test case passes only if the associated feature returns a true value. In case of violation or false result the test case will fail.
· Violation test case: this type of test case passes only if a violation happens while executing this test case. If the test executes without any violations, this type of test case will fail.
· Violation test case with tag: Similar to a violation case, but it expects an exception with a specified tag
All the test cases should be added in the make routine of the root class. There are number of available features from ESpec library that you can use:
add_boolean_test_case (agent f)
· Adds function f as a new boolean test case to the unit test class. This test case passes only when f returns true.
add_violation_test_case (agent r)
· Adds routine r as a new violation test case to the unit test class. This test case only passes if some sort of violation happens while executing r.
add_violation_test_case_with_tag (STRING expected_tag, agent r)
· This feature adds a violation test case r to the unit test class with the expected violation tag. The case will pass only if the expected violation happens.
set_html_name (STRING HTML_filename)
· User can specify the output html file (optional). By default it is CLASS_NAME.html
· This is the mandatory feature that must be put at the end of the make routine of the UNIT_TEST class (if user forgets to put this feature in the make routine, ESpec will not function correctly).
comment (STRING comment)
· This feature may be used in the body of a test case for writing comments.
See the sample projects provided in the ESpec folder for more information.