[ Home Page ] [ Eiffel Archive ] [ Eiffel Classes and Clusters]
![]() |
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.
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 ADDER feature add (a, b: INTEGER) is do Result := a + a end end
Once the test class is written, you run the test cases using the command "etest". Your output should look something like this.
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
Hmmm ... it seems we have a bug in this class.
$ 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)
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.
ETest is available as Open Source under the Eiffel Forum Freeware License.
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.
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]