[ Home Page ] [ Eiffel Archive ] [ Eiffel Classes and Clusters]

Arc de Triomphe clipart (2486 bytes)

ETest: The Eiffel Regression Test Framework

Written by Jim Weirich.

Version 0.9.2

etest-0.9.2.tgz (28,000 bytes) - source code
jweirich@one.net Jim Weirich (maintainer) mail address.

ETest - The Eiffel Regression Test Framework

Table Of Contents

Introduction: Contracts and Testing

Eiffel provides great support for Design by Contract. But the pre- and post-conditions do little good if the code specified by them is not exercised. ETest is a simple regression test framework for Eiffel programs, designed to get the most out of your contracts.

A Simple Example

Suppose you have a class named "ADDER" that added two numbers together and returned the result.
class ADDER
    add (a, b: INTEGER) is
            Result := a + a
You wish to test this class, so you write a simple test case. The test case class inherits from TEST_FIXTURE, which supplies a number of usefull features such as assert_equal. The test class has a single routine called t_addition which makes several assertions about the expected results of the class.
    t_addition is
            a: ADDER
            assert_equal ("1+1", 2, a.add(1,1))
            assert_equal ("1+2", 3, a.add(1,2))
            assert_equal ("2+1", 3, a.add(2,1))
Once the test class is written, you run the test cases using the command "etest". Your output should look something like this.
$ etest
Preparing Test Cases
Compiling Test Cases
Running Test Cases

Test Summary for main

# Passed:     0 tests
# Failed:     1 tests
# Aborted:    0 tests
# Total:      1 tests (3 assertions)

Test Results:
FAIL:  [TEST_ADDER.t_addtion] 1+2 (expected: 3 but got: 2)
Hmmm ... it seems we have a bug in this class.

At this point (well, after you fix the bug), you may wish to run the "etest -w" command do wipe out the temporary files created by ETest.

Other Documentation

Also see the examples and tests directories in the distribution for more examples of using ETest.



You can find ETest at ftp://ftp.one.net/pub/users/jweirich/etest.

ETest is available as Open Source under the Eiffel Forum Freeware License.


ETest was inspired by Kent Beck and Eric Gamma's JUnit, a unit test framework for Java. You can read about JUnit at http://c2.com/cgi/wiki?JavaUnit.

JUnit relies heavily on Java's introspection capabilities to make writing test cases easy. Since Eiffel doesn't (currently) support reflection, ETest uses code generation to ease the test writer's life. The test writer writes just a basic skeleton of code, and the etest perl script will generate all the glue to bring the test case together.

Comments and Feedback

ETest is an ongoing work. I would be happy to hear about what you liked and didn't like, as well as ideas for the future. ETest is an open source project, so feel free to contribute. You can contact me at jweirich@one.net.

Jim Weirich: jweirich@one.net
ETest Home Page: http://w3.one.net/~jweirich/etest/
13 October 1999 (Added to Eiffel Forum Archive: 30 December 1999)

[ Home Page ] [ Eiffel Archive ] [ Eiffel Classes and Clusters]