This site's content was compiled from 1993 to 2006. Beyond that, Google is your friend.
Jim Weirich
EiffelUnit (formerly called ETest) is a simple regression test framework for Eiffel programs, designed to get the most out of your contracts.
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.
EiffelUnit was inspired by Kent Beck and Eric Gamma's JUnit, a unit test framework for Java.
JUnit relies heavily on Java's introspection capabilities to make writing test cases easy. Since Eiffel doesn't (currently) support reflection, EiffelUnit uses code generation to ease the test writer's life. The test writer writes just a basic skeleton of code, and EiffelUnit will generate all the glue code to bring the test case together.
EiffelUnit also includes a wrapper for POSIX regular expressions, and a class to execute external programs.
Obsolete. This package has been incorporated into Gobo Eiffel Test and developed further there.
Suppose you have a class named "ADDER" that added two numbers together and returned the result.
class ADDER feature add (a, b: INTEGER) is do Result := a + a end end
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.
class TEST_ADDER inherit ETEST_FIXTURE feature t_addition is local a: ADDER do !!a 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)) end end -- TEST_ADDER
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.