Unit testing guide
This unit testing guide compiles for the a specific architecture to be run on the same docker container.
Prerequisites
Compiling the unit test
Unit test can be compiled using the below steps:
root@docker:/unify-matter-bridge$ cd /unify-matter-bridge/linux
root@docker:/unify-matter-bridge/linux$ export LD_LIBRARY_PATH=/unify-matter-bridge/linux/out/<arch>_test/gen/stage/lib
root@docker:/unify-matter-bridge/linux$ ../scripts/compile_tests.sh -t <arch>
This generates test binaries inside out/<arch>_test/tests
where test executables can
be found.
Running the unit test
Unit tests are run by first locating your test binary and then executing it.
root@docker:/unify-matter-bridge/linux$ ../scripts/run_tests.sh -b out/<arch>_test
Unit tests can also be executed individually by using the test binary.
root@docker:/unify-matter-bridge/linux$ ./out/<arch>_test/tests/TestExample
'#0:','ExampleTests'
'#3:','Example::TestExample','PASSED'
'#6:','0','1'
'#7:','0','1'
Getting unit test coverage
To understand unit test coverage, run the following helper script:
root@docker:/unify-matter-bridge/linux$ ../scripts/get_test_coverage.sh -t <arch>
Adding new unit test cases.
The Matter bridge test infrastructure leverages the test ecosystem of Matter itself. Writing a unit test is done with the NL Unit test framework and Matter helper functions. Please refer to Test example for an example of how to write a simple unit test. After writing a unit test remember to add the source file in the BUILD.gn.
Refer Cluster Unit Test Case for more details on how to write unit test to test cluster support added to matter bridge.