EUnit Test Framework Overview

What is EUnit?

EUnit stands for EGL Unit testing framework. It is a simple open source framework to write and run repeatable EGL tests. Its features include:

Tooling to generate a test program and run the test cases – Provided by EDT Framework

Manual and automated

Can be run as often as needed (on demand, nightly build, etc.)

GUI and command line interfaces

Logging, reporting, analyzing

Can be used in a multiple-language environment (Java, JavaScript, etc)

Test cases

Test case documentation

EUnit tests are written in EGL. You write the tests in a normal EGL project, then use the EUnit tooling to create a "test driver" for each target language you want to test in. The test driver is runnable code (a Java program or a JavaScript RUIHandler) that will execute the tests and create a report of their results.

How to write test cases using EUnit

1. Create an EGL Project, for example: eunit.test

Select Basic as the template.

Select the generators:

1) If you will run the testing on both Java and JavaScript platforms, leave the default settings (both Java and JavaScript generators selected).

2) If you will run the testing on a specific platform, select Override generation settings from workspace preferences and choose a generator.

2. Create an EGL Library, for example: test, and provide a package name, such as libs.

3. Open the library with the EGL Editor, and remove the automatically generated code.

4. Type the variable declarations and functions (we treat each function as an EUnit test case) in the library. Functions that perform a test should have the @Test annotation. For example:

Creating the test driver

The name of the test driver project will be the name of your EUnit project, plus eunit.java or eunit.javascript.

You must re-create your test driver if you add or remove @Test functions in the EUnit project. But you don't have to re-create the test driver if you modify an existing @Test function.

Tips

You can create a test driver from packages or egl files instead of an entire project.

How to run tests using EUnit

Java

Go to the EGLSource folder of the test driver project and run eunitgen.RunAllTests_pgm.egl as an EGL Java Main Application.

JavaScript

There are two ways to execute the test:

Go to the EGLSource folder of the test driver project, and run eunitgen.RunAllTests_rui.egl as an EGL Rich UI Application.

Go to the EGLSource folder of the test driver project, and deploy the eunit_javascript.egldd file to a target project. Start the server and then run the HTML file in the browser.

Viewing the results

Refresh your test driver project. You should see a new folder, ResultRoot. It will have a subfolder whose name is a timestamp of the form yyyymmdd_hhmmss. Expand the subfolder and open the file ResultSummary.trs. You'll see a summary of the results. If you have BIRT installed you'll also see the results in a pie chart.
You can also go through every individual report by clicking the leaf node of the result tree and navigating to the corresponding source file.