Difference between revisions of "Testing Tool (Specification)"
(Added links to other testing related pages) |
(Commented example tests) |
||
Line 4: | Line 4: | ||
=== Add unit/system level tests === | === Add unit/system level tests === | ||
+ | |||
+ | Semantically there is no difference between unit tests and system level tests. This way all tests can be written in Eiffel. A test is a routine in a class inheriting from '''TEST_SET'''. Test routines must be exported to any and have the prefix '''test'''. | ||
Example unit tests '''test_append''' and '''test_boolean''' | Example unit tests '''test_append''' and '''test_boolean''' | ||
Line 51: | Line 53: | ||
− | Example system level test '''test_version''': | + | Example system level test '''test_version''' (Note: '''SYSTEM_LEVEL_TEST_SET''' inherits from '''TEST_SET''' and provides basic functionality for executing external commands, including the system currently under development): |
<eiffel> | <eiffel> | ||
Line 59: | Line 61: | ||
inherit | inherit | ||
− | + | SYSTEM_LEVEL_TEST_SET | |
feature -- Test routines | feature -- Test routines |
Revision as of 08:51, 6 June 2008
Contents
Main functionalities
Add unit/system level tests
Semantically there is no difference between unit tests and system level tests. This way all tests can be written in Eiffel. A test is a routine in a class inheriting from TEST_SET. Test routines must be exported to any and have the prefix test.
Example unit tests test_append and test_boolean
class TEST_STRING inherit TEST_SET redefine set_up end feature {NONE} -- Initialization set_up do create s.make (10) end feature -- Access s: STRING feature -- Test routines test_append require set_up: s /= Void and then s.is_empty do s.append ("12345") assert_string_equality ("append", s, "12345") end test_boolean require set_up: s /= Void and then s.is_empty do s.append ("True") assert_true ("boolean", s.is_boolean and then s.to_boolean) end end
Example system level test test_version (Note: SYSTEM_LEVEL_TEST_SET inherits from TEST_SET and provides basic functionality for executing external commands, including the system currently under development):
class TEST_MY_APP inherit SYSTEM_LEVEL_TEST_SET feature -- Test routines test_version do run_system_with_args ("--version") assert_string_equality ("version", last_output, "my_app version 0.1") end end