Actions
UnitTesting » History » Revision 5
« Previous |
Revision 5/12
(diff)
| Next »
Junxiao Shi, 02/15/2015 06:57 PM
Unit Testing¶
NFD requires unit testing for most modules.
NFD uses Boost Unit Test Framework.
Learning Resources for Boost Unit Test Framework¶
- Boost Unit Test Framework documentation
- After compiling the unit-test binary, it is possible at run time to select which tests to run and what kind of output is desired.
Use--help
command line option to get more information about the available options.
Testing Code Guidelines¶
- Test suite for
.../folder/module-name.hpp
should be placed intests/.../folder/module-name.t.cpp
.- For example, test suite for
daemon/fw/forwarder.hpp
should be place intests/daemon/fw/forwarder.t.cpp
.
- For example, test suite for
- Test suite should be named
FolderModuleName
.- Exception: test suite for a header in top-level folder is named
TestModuleName
so that unqualifiedModuleName
still refers to the tested type. - For example, test suite for
daemon/fw/forwarder.hpp
is namedFwForwarder
, test suite forsrc/name.hpp
is namedTestName
.
- Exception: test suite for a header in top-level folder is named
- Test suite should be declared inside the same namespace of the tested type plus additional
tests
namespace.- For example, test suite for
nfd::Forwarder
is declared innfd::tests
, test suite fornfd::cs::Cs
is declared innfd::cs
. - If needed, parent
tests
sub-namespace can be imported withusing namespace
directive.
- For example, test suite for
- Test suite should use
nfd::tests::BaseFixture
fixture, to get automatic setup and teardown of globalio_service
.- If a custom fixture is defined for test suite or test case, that custom fixture should derive from
BaseFixture
. IdentityManagementFixture
should be used if a test case needs to create identities in KeyChain.UnitTestTimeFixture
should be used if mocked clocks are feasible/desirable.
- If a custom fixture is defined for test suite or test case, that custom fixture should derive from
Testing Helpers¶
tests/core/limited-io.hpp
provides operation count and time limittests/daemon/face/dummy-face.hpp
provides aFace
that doesn't depend on a sockettests/daemon/fw/strategy-tester.hpp
provides a facade to test a forwarding strategytests/daemon/fw/topology-tester.hpp
provides facilities to test forwarder and strategy in a virtual topology
Updated by Junxiao Shi almost 10 years ago · 12 revisions