735
edits
m (→References: https://sourceforge.net/p/flightgear/mailman/message/36985403/) |
(Add useful information on building and running the test suite.) |
||
Line 1: | Line 1: | ||
{{ | {{Note|There’s already the test_suite in flightgear/test_suite using [[Cppunit effort|CppUnit]], thanks to some hard work by [[User:Bugman|Edward]]. We need more tests written for it, submissions welcome. (Pick an area of interest)<ref>https://sourceforge.net/p/flightgear/mailman/message/36972720/</ref>}} | ||
FlightGear has a small (but hopefully growing!) set of Unit Tests. These are small tests designed to quickly test small pieces of code. That constrasts with more broadly scoped functional and system tests. | |||
== Building the test suite == | |||
To run the tests you will need to build FlightGear from source using cmake. See [[Building FlightGear]] for details. | |||
Once you have your cmake build environment do the following: | |||
# Change to your FlightGear build directory | |||
# Enable building the tests by setting a cmake variable: <code>cmake -LBUILD_TESTING=ON .</code> | |||
# Build the test suite: <code>make test_suite</code> | |||
This will also run the full test suite (see below), because you will typically want to write a test and then immediately compile and run it. | |||
== Running the test suite == | |||
To run the test suite, simply run <code>./test_suite/fgfs_test_suite</code> | |||
This will run the full test suite and print a Synopsis of results similar to the following: | |||
Synopsis | |||
======== | |||
System/functional tests ....................................... [ OK ] | |||
Unit tests .................................................... [ OK ] | |||
Simgear unit tests ............................................ [ OK ] | |||
FGData tests .................................................. [ OK ] | |||
Synopsis ...................................................... [ OK ] | |||
You can also run individual test cases. Run <code>./test_suite/fgfs_test_suite -h</code> to see the various options | |||
== Why write unit tests? == | |||
A well tested piece of software will have a much lower bug count/load. An extensive test suite with '''unit tests''', system/functional tests, GUI tests, installer tests, and other categories of tests can significantly help in this regard. | A well tested piece of software will have a much lower bug count/load. An extensive test suite with '''unit tests''', system/functional tests, GUI tests, installer tests, and other categories of tests can significantly help in this regard. | ||
Line 30: | Line 61: | ||
* Low code quality and standards. This is related to the learning point. As long as a test compiles on all OSes without warning, it passes, and Valgrind gives you an ok, it is good enough. You dont need to be a C++ expert to dive into this shallow end of the pool. | * Low code quality and standards. This is related to the learning point. As long as a test compiles on all OSes without warning, it passes, and Valgrind gives you an ok, it is good enough. You dont need to be a C++ expert to dive into this shallow end of the pool. | ||
== Bootstrapping new tests == | == Bootstrapping completely new tests == | ||
To start diving strait into the test suite code, firstly copy what has | To start diving strait into the test suite code, firstly copy what has | ||
been done in this commit: https://sourceforge.net/u/edauvergne/flightgear/ci/8474df | been done in this commit: https://sourceforge.net/u/edauvergne/flightgear/ci/8474df |