Implementing test cases

From GNUstepWiki

GNUstep now has a test framework included as part of the gnustep-make package. It has no external dependencies other than the tools needed to build GNUstep itself ... so if you can build code you are guaranteed to be able to produce tests for it.

Similarly, if you install gnustep-make on an Apple OSX system, you can run test cases there against the Apple implementation of the code ... this is great for ensuring that GNUstep implementation of common APIs not only behaves s documented, but also matches the details of Apple's implemented behaviours.

You execute test cases using the gnustep-tests command.

Try 'gnustep-tests --help' to list the available options.

Try 'gnustep-tests --documentation' for full documentation on how to run tests.

Look in $GNUSTEP_MAKEFILES/TestFramework for examples of how to use the framework.

For gnustep-base test cases, look in the Tests/base subdirectory in the gnustep-base package

For gnustep-gui test cases, look in the Tests/gui subdirectory in the gnustep-gui package

When getting started, it makes particular sense to look at the functions in $GNUSTEP_MAKEFILES/TestFramework/ObjectTesting.h (and look at examples of their use in the base and gui test cases). These functions allow you to test a lot of basic stuff without having to write any test cases of your own:

For instance, test_alloc() can be used to test that your class supports instance allocation and deallocation properly and test_NSObject() can be used to check that your class correctly implements the methods of the NSObject protocol).