there’s no excuse not to do bdd/tdd/ci (and many more) in cross-platform c++ projects
All tests are run on travis-ci:
See the config for details: .travis.yml
see commits and:
- simple premake-based build config: premake4.lua
- lightweight testing based on catch: src/catch/simple.cpp
- polymorphic mocks based on googlemock: src/gmock/mocks.cpp
- lightweight bdd-style tests using catch: src/catch/bdd_style.cpp
- cucumber-cpp-based behavior-style spec/tests: features/elements.feature, src/cucumber/cppspec_steps.cpp
- hayai-based simple and informative microbenchmarking: src/hayai/to_string_benchmark.cpp
- scripted testing without recompiles (i.e. for data-driven tests) using a lua binding via LuaBridge, and a behavior spec for testing with busted
- an exploratory example for Visual Studio and SpecFlow can be found in src/cppcli
generating build files
[path_to]/premake5 --help to find a suitable
if a feature is not implemented for the chosen platform in premake5, try premake4, since premake5 is still in “alpha”.
customizing BOOST location (MS Windows)
in premake4.lua prior to
boost:set_* calls, the paths to BOOST can be customized.
Either the environment variable
BOOST should be set to the BOOST root, or it can be set directly, i.e.
boost.includedirs.windows = [[d:\\my_boost\1.55]].
The library paths are typically more complex, thus
boost:set_libdirs() uses a pattern (see substitutions boost.lua, based on BOOST binaries).
boost.libdirs_pattern.windows can be modified according to the installation, i.e.
boost.libdirs_pattern.windows = path.join(boost.includedirs.windows,'lib/$(PlatformTarget)')
If you use boost in a custom configuration and you have to set defines, you can add defines in similar fashion:
local d = boost.defines.windows d[#d+1] = 'BOOST_REGEX_...' d[#d+1] = 'BOOST_....WHATEVER'
running cucumber steps
prerequisite: cucumber should be installed
Start cucumber and the steps runner using
[path_to]/premake4 cucumber. The actual command line is
bin/[path_to]/cucumber_example > /dev/null & cucumber on *X, and
start bin\[path_to]\cucumber_example && cucumber on MS Windows.
running busted tests
- [ ] property based testing using rapidcheck