Skip to content
Per Andersson edited this page Jan 6, 2014 · 8 revisions

See playtest.tests project for more information.

Information about the playtest.tests project

  1. Create an executable project
  2. Add necessary external include- and library folders
  3. Add the actual external dependencies
  4. Add Post-Build event
  5. Add unit tests

Create an executable project

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)

Add necessary external include- and library folders

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).

Add the actual external dependencies

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

Add Post-Build event

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.

Add unit tests

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.

Custom test runner

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.