-
-
Notifications
You must be signed in to change notification settings - Fork 89
Initial unit tests based on GoogleTest and GoogleMock #794
Copy link
Copy link
Closed
Labels
Description
@akuker @rdmark The feature_google_test branch contains some initial unit tests based on GoogleTest, which I would like to be commented on before more time is spent on them. The relevant changes only affect the Makefile and add one additional source file in the new "test" folder.
Some notes:
- There does not seem to be a pre-compiled GoogleTest for Raspberry Pi OS. I don't see an issue with that because as long as the unit tests are hardware-independent (otherwise they might rather be classified as integration tests) they run on any platform. Currently I run them on a regular Linux PC, which is a better development environment than the Pi anyway.
- The tests are built and run with the "make test" target. The default "make" target tdoes not build them, so there are no compile-time issues (see above) on the Pi, and compiling on the Pi does not take longer than before.
- In order to test not just a small part of the code but to have a substantial amount of tests, a lot of refactoring of the existing code may be required. The current code still lacks the required granularity and encapsulation. But it is normal the adding tests has an influence on your code structure, and you have to start somewhere ;-).
- Restructure project folders to better accommodate (C++) unit tests #455 may have to be revisited at some point in time, but only if there are ever enough tests to justify spending time on Restructure project folders to better accommodate (C++) unit tests #455. There are already too many tickets that were started but are now in a rather undefined/unfinished state ...
>make test
./bin/fullspec/rascsi_test
Running main() from /var/tmp/portage/dev-cpp/gtest-1.11.0/work/googletest-release-1.11.0/googletest/src/gtest_main.cc
[==========] Running 2 tests from 1 test suite.
[----------] Global test environment set-up.
[----------] 2 tests from ModePagesTest
[ RUN ] ModePagesTest.SCSIHD_AddModePages
[ OK ] ModePagesTest.SCSIHD_AddModePages (0 ms)
[ RUN ] ModePagesTest.ModePageDevice_AddModePages
[ OK ] ModePagesTest.ModePageDevice_AddModePages (0 ms)
[----------] 2 tests from ModePagesTest (0 ms total)
[----------] Global test environment tear-down
[==========] 2 tests from 1 test suite ran. (0 ms total)
[ PASSED ] 2 tests.
Reactions are currently unavailable