background preloader

Scons

Facebook Twitter

UnitTests - SCons Wiki - Vimperator. Want to have "scons test" run your unit tests?

UnitTests - SCons Wiki - Vimperator

Here are two suggestions: running with an Alias running with Command See for another suggestion. To have the process of adding unit test nicely encapsulated into an scons Tool, see the section below - "Unit Test integration with an scons Tool". shows a way to make adding UnitTests very simple by using CxxTest and automatically finding unit tests in a test directory. Toggle line numbers 1 2 program = env.Program('test', 'TestMain.cpp') 3 4 test_alias = Alias('test', [program], program[0].path) 5 6 AlwaysBuild(test_alias) Check out PhonyTargets for another way of defining a 'test' target. Note that program[0].path might give issues when running on OS'es that do not explicitly search for executables in the current directory (Unix-like OS'es where you explicitly need to add '.' as a search path). 1 2 program = env.Program('test', 'TestMain.cpp') 3 4 test_alias = Alias('test', [program], program[0].abspath) 5 6 AlwaysBuild(test_alias)

C++ Unit Testing With Boost.Test - Vimperator. Recently I implemented a Pulse plugin to read Boost.Test reports and integrate the tests into the build results.

C++ Unit Testing With Boost.Test - Vimperator

As usual, the first step in implementing the plugin was the creation of a small project that uses Boost.Test to produce some real reports to work from. I found the Boost.Test documentation to be detailed, but not so easy to follow when just getting started — so I thought I’d give an overview here. Step 1: Installation First you will need to install Boost.Test, or possibly all of Boost if you plan to use more of it. You can download Boost in its entirety from the Boost download page.

An even easier option if you are on Linux is to install a package. The downside of this is the packages are somewhat out of date, the default being built from Boost 1.34.1 (there is also a 1.35 variant available). Step 2: Choose Your Compilation Model With that plumbing out of the way, we can get down to testing something. Step 3: A First Test Case Simple enough, my test passes. Step 5: Suites Update.

Spaceblog - Vimperator. The scons-users mailing list has a few references to how people have implemented unit tests in their build, very few of those are accompanied by code examples.

spaceblog - Vimperator

The SCons wiki has a page on unit tests, which sucks to say the least. What I want is what Greg Ward wants: all the tests should run when one types scons check. If SCons builds nothing, the unit tests should also not run if the unit test source changes, the unit test should be built and run if code that the test links or includes changes, the test should be rebuilt and run The second part is pretty easy, actually. Test = env.Program('test.c') env.AddPostAction(test, test[0].abspath) and as long as your test program is self contained (i.e. it's a real unit test and not a subsystem test framework, i.e. testing various inputs as they go through your parser, say) then it just works.

You can build the first rule with an Alias -- SCons will let you append targets to an Alias to accumulate what that alias does: