Difference between revisions of "Testing"

From VDrift
Jump to: navigation, search
m (2 revisions: Import from old wiki (on 15 May 2012))
 
m (Formatting style updates)
Line 3: Line 3:
 
==Running the Tests==
 
==Running the Tests==
 
To run unit tests, the test executable must first be built.
 
To run unit tests, the test executable must first be built.
 +
 
===Building===
 
===Building===
 
In the VDrift source root, run:
 
In the VDrift source root, run:
 
  scons test
 
  scons test
 +
 
===Executing===
 
===Executing===
 
The executable is called '''vdrift-test''' and is compiled to the '''build/''' directory in the root of the VDrift source tree. To run it, simply do:
 
The executable is called '''vdrift-test''' and is compiled to the '''build/''' directory in the root of the VDrift source tree. To run it, simply do:
 
  build/vdrift-test
 
  build/vdrift-test
 +
 
===Results===
 
===Results===
 
The results are written to STDOUT. An example:
 
The results are written to STDOUT. An example:
 
 
  [-------------- RUNNING UNIT TESTS --------------]
 
  [-------------- RUNNING UNIT TESTS --------------]
 
  src/matrix4.cpp(26): 'matrix4_test' FAILED: value1 (1) should be close to value2 (0)
 
  src/matrix4.cpp(26): 'matrix4_test' FAILED: value1 (1) should be close to value2 (0)

Revision as of 08:37, 27 August 2012

VDrift includes a very simple unit testing framework for C++ code. It is derived from QuickTest.

Running the Tests

To run unit tests, the test executable must first be built.

Building

In the VDrift source root, run:

scons test

Executing

The executable is called vdrift-test and is compiled to the build/ directory in the root of the VDrift source tree. To run it, simply do:

build/vdrift-test

Results

The results are written to STDOUT. An example:

[-------------- RUNNING UNIT TESTS --------------]
src/matrix4.cpp(26): 'matrix4_test' FAILED: value1 (1) should be close to value2 (0)
src/matrix4.cpp(27): 'matrix4_test' FAILED: value1 (10) should be close to value2 (20)
src/matrix4.cpp(28): 'matrix4_test' FAILED: value1 (-1.19209e-07) should be close to value2 (-1)
src/matrix4.cpp(33): 'matrix4_test' FAILED: value1 (1) should be close to value2 (0)
src/matrix4.cpp(34): 'matrix4_test' FAILED: value1 (10) should be close to value2 (0)
src/matrix4.cpp(35): 'matrix4_test' FAILED: value1 (-1.19209e-07) should be close to value2 (1)
Results: 29 succeeded, 1 failed
[-------------- UNIT TESTS FINISHED -------------]

Writing New Tests

Consult the QuickTest How to Use It and the QuickTest API Reference for details on how to write unit tests using QuickTest.

Example Tests

To look at some example test code already in VDrift, look at src/*.cpp files which contain the macro QT_TEST.