Test

by Deadron
A test framework that makes it very easy to test your game, using Extreme Programming principles.
ID:56154
 
This library makes it easy for you to create unit tests (tests of small pieces of functionality) as recommended by the Extreme Programming principles. You can read more on this style of testing at this Wiki site.

I have also written a BYONDscape article explaining the approach of this library.

The library simply provides the dd_run_tests() proc for you to call, which automatically runs all tests that are part of the /obj/test object.

For this to work, there are three simple requirements:

1) All the tests must be defined as verbs on the test object, such as:

obj/test/verb/mytest()

2) When a test fails, it should call the test object's die() proc:

obj/test/verb/isValidName_test()
if (!isValidName("Deadron"))
die("isValidName() didn't allow legal name: Deadron")

3) To make sure your tests never collide with someone else's tests, you can use your own subclass of the test object, like so:

obj/test/MyClass/verb/isValidName_test()
if (!isValidName("Deadron"))
die("isValidName() didn't allow legal name: Deadron")

The library will automatically find your class and execute the tests.

To see the tests in action, you can run the library stand-alone, which will start up the demo code.

May 24, 2006
- Added dd_testing global variable that indicates whether a test is currently being run. This allows you to skip some code or otherwise conditionalize code if a test is running.