I have a Boost unit test case which causes the object under test to throw an exception (that's the test, to cause an exception). How do I specify in the test to expect that particular exception.
I can specify that the test should have a certain number of failures by using BOOST_AUTO_TEST_CASE_EXPECTED_FAILURES but that seems rather unsp...
I know there are already a few questions regarding recomendations for c++ unit test frameworks, but all the answers did not help as they just recomend one of the frameworks but do not provide any information about a (feature) comparison.
I think the most interesting frameworks are CppUnit, Boost and the new Google testing framework. Has...
Hi
I'm new to Boost.Spirit and Boost.Test and I would like to know how you verify the correctness of your grammars. Below is a simplified version of how I do it at the moment and I'm pretty sure that there's a better way:
Each test case hase a pair of two strings containing the text to parse and the expected result delimited by semicol...
I've used both CppUnit and boost::test for C++ unittesting. Generally I prefer boost::test, mainly because the auto-test macros minimise the effort to setup tests. But there's one thing I really miss from CppUnit: the ability to register your own "protectors", instances of which automatically wrap all the run tests. (Technically, you ...
Hello :)
I'm getting started with Boost::Test driven development (in C++), and I'm retrofitting one of my older projects with Unit Tests. My question is -- where do I add the unit test code? The syntax for the tests themselves seems really simple according to Boost::Test's documentation, but I'm confused as to how I tell the compiler to...
Hello :)
I'm a bit confused on setting up the boost test library. Here is my code:
#include "stdafx.h"
#define BOOST_TEST_DYN_LINK
#define BOOST_TEST_MODULE pevUnitTest
#include <boost/test/unit_test.hpp>
BOOST_AUTO_TEST_CASE( TesterTest )
{
BOOST_CHECK(true);
}
My compiler generates the wonderfully useful error message:
1>MSVC...
I've got a unit test I'm writing which seems to have some kind of a pointer problem. Basically, it's testing a class that, once constructed, returns information about a file. If all the files expected are detected, then the test operates correctly. If there are more files expected than detected, then the routine correctly reports error. ...
Or Can I use it in regular code?
If the answer is "no", then is there C++ library that will provide me with all the macros like CHECK_EQUAL, CHECK_CLOSE, etc.?
...
I'm just getting stated with boost-test and unit testing in general with a new application, and I am not sure how to handle the applications initialisation (eg loading config files, connecting to a database, starting an embedded python interpretor, etc).
I want to test this initialisation process, and also most of the other modules in t...
I am trying to use Boost Test to add some much needed unit tests to my code. However I can't seem to get it to work. Right now I have the following code
#include <Drawing.h>
#define BOOST_AUTO_TEST_MAIN
#define BOOST_TEST_MODULE DrawingModelTests
#include <boost/test/unit_test.hpp>
BOOST_AUTO_TEST_SUITE(DrawingModelTests)
BOOST_AUTO_T...
I'm using the Boost::Test library, and I am trying to check if an actual percent value is close to the expected value:
BOOST_CHECK_CLOSE_FRACTION(
items[i].ExpectedPercent,
items[i].ActualCount / totalCount,
0.05);
For some reason this check fails even when the values are close enough:
difference between items[i].Expected...
I previously asked this question under another name but deleted it because I didn't explain it very well.
Let's say I have a class which manages a file. Let's say that this class treats the file as having a specific file format, and contains methods to perform operations on this file:
class Foo {
std::wstring fileName_;
public:
...
Hi
Does anybody know how to register my custom exception translator when using auto test cases in Boost.Test? I've found some examples (very few actually), but they do not show how to use this feature with auto test cases which are the biggest advantage of boost.test in my opinion. My example test suite:
#define BOOST_TEST_MODULE S...
The following does not compile:
class Foo {
public:
Foo( boost::shared_ptr< Bar > arg );
};
// in test-case
boost::shared_ptr< Bar > bar;
BOOST_CHECK_THROW( Foo( bar ), std::logic_error ); // compiler error here
The implementation of Bar does not matter. The compiler complains, that Foo does not have an appropriate default cons...
Hi all,
I'm using Eclipse CDT and Boost.Test(with Boost.Build).
I would like Eclipse to parse output of Boost.Test generated during by run of test suites during build.
Does anybody know how to achieve this?
Thanks in advance
...
I have some C++ projects running through cruisecontrol.net. As a part of the build process, we compile and run Boost.Test unit test suites. I have these configured to dump XML log files. While the format is similar to JUnit/NUnit, it's not quite the same (and lacks some information), so cruisecontrol.net is unable to pick them up. I ...
We use Boost statically linked with our app but now I wan't to use Boost Test with an external test runner and that requires the tests themselves to link dynamically with Boost.Test through the use of the required BOOST_TEST_DYN_LINK define.
Is this going to be a problem or is the way Boost Test links completely unrelated to the way the...
I've been using CppUnit for quite a while now (and am happy with it). As we are using more and more parts of the boost library I had a short look on boost.test and I'm wondering now if I should switch to boost.test in a new project or not.
Can anyone here tell me about the differences between the two frameworks and the benefits (if ther...
I'm using Boost.Test for Unit testing and am currently running various mock servers in separate threads which get launched from within each test. In order to more accurately test my code the mock server's should really be in separate processes.
I was thinking about doing something along these lines:
MY_TEST()
if (fork() == 0) {
r...
I am using an aggregate initializer to set up a block of static data for a unit test.
I would like to use the array size as the expected number of elements, but this can fail if too few initializers are provided:
my_struct_type expected[14] =
{
{ 1.234, 0, 'c' },
{ 3.141, 1, 'z' },
{ 2.718, 0, 'a' }
};
This gives no compi...