-
Notifications
You must be signed in to change notification settings - Fork 0
Tutorial
See playtest.tests project for more information.
- Create an executable project
- Add necessary external include- and library folders
- Add the actual external dependencies
- Add Post-Build event
- Add unit tests
The actual project name might be different depending on what IDE you're using. The project must be executable. If you are using the default build, then a console application is recommended.
You might be asking why are we creating an actual test project? There are two reasons. The first reason is to prevent us from mixing test code and actual application code. We don't want to ship these types of tests to the end-user. If this is you're requirement, then this unit-test framework might not be for you. The second reason is because we want to be able to create a post build step in the build-chain. (Read step 4 for more information)
This is so that you're IDE can find the actual header- and library files during build. The external include path should point so that the editor finds the header file when writing
#include <playtest/playtest.h>The external library path should point so that the editor finds the file when adding playtest.lib as an external library (file suffix differs depending on what operating system you're using).
File suffixes differs depending on what operating system you're using
The most common user need the following external libraries for a DEBUG build:
- playtest_d.lib
- playtest.runner_d.lib
or RELEASE build:
- playtest.lib
- playtest.runner.lib
This might no be possible using the editor you're using. But the idea is that the editor executes the console application where all the unit-tests are located during compilation. Microsoft Visual Studio 2010 calls this Post-Build event. Add the path to the compiled file in this property.
After you've created and configured the project, it's time to add your own unit-tests. Although not required, it's recommended to create one source file (.cpp) for each test-suite.
The playtest runner supplied with the library evaluates all the test-cases and prints the result into the console. You might have other requirements. If that's the case then remove the playtest.runner external dependency from you're build-chain and add your own main function. See playtest.runner project for more information.