EUnit is a framework used to write and run repeatable test cases and to create reports about the results. The framework code is in the org.eclipse.edt.eunit.runtime package.
An interactive process is available for running tests. A batch mechanism is planned to let you run tests automatically; for example, to run tests overnight. However, only the interactive process is in place in version .7.
To write test cases, code an EGL library and document it in a way that provides details for display in the output report. A set of library functions implement your test cases, one function per test case.
package common; import org.eclipse.edt.eunit.runtime.LogResult; import org.eclipse.edt.eunit.runtime.Test; import org.eclipse.edt.eunit.runtime.status; /** @test * @description Test cases for demonstration * @keywords Comparisons, Skips **/ library MyTestCases function test01() {@Test} // do processing here, as appropriate for the test case. a int = 100; b int = 50; success boolean = a > b; LogResult.assertTrue("Test for one integer greater than the other. ", success); end function test02() {@Test {targetLang = [Java, JavaScript]}} // do processing here, as appropriate for the test case. a string = "first"; b string = "last"; LogResult.assertStringEqual("Test for two equal strings. ", a, b); end function test03() {@Test} // do processing here, as appropriate for the test case. myTrue boolean = true; myFalse boolean = true; // expected myFalse to be false if (myTrue==myFalse) LogResult.failed("Failed to distinguish between true and false. "); else LogResult.passed("Logic is correct."); end end function test04() {@Test} LogResult.skipped("Waiting to resolve bug 2525"); return; // remove the previous two lines when the bug is resolved. // do processing here, as appropriate for the test case. end function test05() {@Test{targetLang = [Java]}} myException MyExceptionType; try // do processing here, as appropriate for the test case. throw new MyExceptionType{message = "An unexpected exception"}; onException (except AnyException) LogResult.error(except.message); end end end Record MyExceptionType type Exception end
If you are comparing one record, handler, or external type to another, invoke a series of LogResult functions, one for each field value of interest.
For details on those functions, see the following EGL Language Reference entry: LogResult external type.
A test driver is a project from which you run the test cases. A test driver is language specific, including only the test cases that were targeted for a given language.
The library-specific report includes a msg: title, and after that title is the content of the logged messages for that library.