-
-
Notifications
You must be signed in to change notification settings - Fork 17
Unit tests on server code
Unit Tests are develop with the Boost Unit Test Framework.
The the unit test boost libray must be build. Follow the Boost build procedure from How-to-build-from-sources
The just add --with-test to b2 command line
Example for Windows :
b2.exe --with-test --with-atomic --with-chrono --with-date_time --with-filesystem --with-regex --with-thread --with-system link=shared
The root directory is the following /trunk/tests/unit/
the structure is the following:
- sources : all sources of tests
- builds : directory where executables will be find after the compilation.
- projects: All projects files or makefile (generated) are here.
After the checkout operation, you have to generate makefiles with following batches for your operating system at the root :
- cmake_linux_tests.sh
- cmake_macosx_tests.sh
- cmake_raspberry_tests.sh
- cmake_windows_tests.cmd
Generate tests with Visual Studio by opening the project into the projects directory, or enter the make command into linux or Raspberry.
The execution file will be into the builds directory (/trunk/tests/builds/{DEBUG or RELEASE}). Launch it by the command yadomsTests.exe or ./yadomsTests under Linux.
To debug tests under Windows/VisualStudio, set YadomsTests as startup project, and working directory as '${TargetDir}' (Properties of YadomsTests project, Debugging section).
To run/debug a particular test, add --run_test=myTest to start argument (myTest is the test name declared with BOOST_AUTO_TEST_SUITE macro).
The Unit test file should be in the same directory like the initial development.
Example :
You have created a plugin at this position : trunk/sources/plugins/FakePlugin You have to create tests files at this position : trunk/tests/sources/plugins/FakePlugin/.
Your Plugin directory should be include into the CMakeLists.txt file with the following line:
add_subdirectory(FakePlugin)You should have a CMakelists.txt file into your directory. This file will have the following struture:
IF (NOT DISABLE_TEST_FAKEPLUGIN)
ADD_YADOMS_SOURCES(
... Add here your sources files to be included for the compilation ...
)
ADD_SOURCES( ...Add here Unit test Files... )
...To be more readable each test file could be enter in a separate structure with his own source files (it is not necessary)...
ENDIF()
Yadoms -- The ultimate house automation solution