boost-test

How to print test summary using boost unit test

我与影子孤独终老i 提交于 2019-12-05 16:57:38
Is there a way to print a summary of the tests run in boost unit test. In particular, can a listing of the failed tests be made? I'm having a hard time locating failing tests in the output (especially when the tests have their own output). I already set BOOST_TEST_LOG_LEVEL in order to show enter/exit, but that isn't enough to locate the failing tests. Gennadiy Rozental Use the option: --report_level=detailed It will report all your tailing test cases and suites. 来源: https://stackoverflow.com/questions/10620712/how-to-print-test-summary-using-boost-unit-test

boost unit test - list available tests

送分小仙女□ 提交于 2019-12-05 16:21:47
I've written some scripts to automate the running of our unit tests, written using the boost unit testing framework. I'd like to add functionality to allow the selection and subsequent running of a subset of all tests. I know I can run a subset of tests using the run_test argument, but I can't find a way to list all tests that are in a compiled binary, i.e. all the argument values I can pass to run_test. Is there a way to extract all available tests, or will I have to write a custom test runner? If so, where do I start? Documentation for the internals of boost::test can be a bit lacking, that

Testing a DLL with Boost::Test?

僤鯓⒐⒋嵵緔 提交于 2019-12-05 13:54:47
I am developing a DLL in C++ and want to perform unit testing of that DLL using the Boost Test Libraries. I read the Boost test manual thoroughly but since I am new, I have the following question: Should I add test classes in the same VC project in which I am developing my DLL?. Ideally I want to do this but I am confused that a DLL has no main() and, on the other hand, the Boost test needs its own main() to execute. So where does the Boost test output go in this scenario? (In fact, I practically implemented this and don't see any output :( and almost spent two days I figuring out the problem,

How do you specify that an exception should be expected using Boost.Test?

拟墨画扇 提交于 2019-12-05 08:56:26
问题 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 unspecific. I want to be able to say at a specific point in the test that an exception should be thrown and that it should not be counted as a failure. 回答1: Doesn

Boost test does not init_unit_test_suite

▼魔方 西西 提交于 2019-12-05 02:32:37
I run this piece of code #define BOOST_TEST_MAIN #define BOOST_TEST_DYN_LINK #include <boost/test/unit_test.hpp> #include <boost/test/unit_test_log.hpp> #include <boost/filesystem/fstream.hpp> #include <iostream> using namespace boost::unit_test; using namespace std; void TestFoo() { BOOST_CHECK(0==0); } test_suite* init_unit_test_suite( int argc, char* argv[] ) { std::cout << "Enter init_unit_test_suite" << endl; boost::unit_test::test_suite* master_test_suite = BOOST_TEST_SUITE( "MasterTestSuite" ); master_test_suite->add(BOOST_TEST_CASE(&TestFoo)); return master_test_suite; } But at runtime

Where to find the parsed Boost.Test output in Eclipse

天大地大妈咪最大 提交于 2019-12-05 00:37:05
There is already a thread here that partially answers my question . On Eclipse 3.7.2 I followed the approach provided there and I could successfully accomplish the steps creating and setting up a new error parser and adding it to my current project. After executing my Boost.Test (boost rel. 1.48.0) Unit Test, on the Eclipse console I get the same output as the output I get when no parsing is done (e.g. when executing the Unit Test outside Eclipse (e.g. on a Linux terminal)). I searched for a new Eclipse console where the parsed Unit Test output could be displayed (similar to the consoles by e

getting all boost test suites / test cases

最后都变了- 提交于 2019-12-04 10:58:17
As the title says, I want to get all test suites or test cases (name) from a test application, ether in the console or as xml output. Test framework is the boost test library. Is there an option to achieve this? I did not found anything useful in the documentation. ToniBig This can be done without much intrusion using a global fixture . Assuming you have a translation unit (cpp file) that contains main explicitly or auto generated, you can intercept test execution when a certain command line argument is provided. Then you can traverse the test tree using a customized visitor, which lists all

Problem with BOOST_CHECK_CLOSE_FRACTION

﹥>﹥吖頭↗ 提交于 2019-12-04 07:44:27
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].ExpectedPercent{0.40000000000000002} and items[i].ActualCount / totalReturned{0.42999999999999999} exceeds 0.050000000000000003 Is this a problem with Boost or a problem with how I am using Boost? After some testing, it turns out that the documentation for BOOST_CHECK_CLOSE_FRACTION

Boost's data-driven tests' join operator `+` corrupts first column

≯℡__Kan透↙ 提交于 2019-12-04 07:42:50
Consider the following code: BOOST_DATA_TEST_CASE( sampleTest, (data::make(1) ^ data::make(2)) + (data::make(3) ^ data::make(4)), var1, var2) { std::cout << var1 << "," << var2 << std::endl; } The output I expect is: 1,2 3,4 However, var1 appears to be corrupt: $> ./MyTests --run_test=Tests/sampleTest Running 2 test cases... 202875304,2 202875304,4 *** No errors detected $> ./MyTests --run_test=Tests/sampleTest Running 2 test cases... 83976616,2 83976616,4 *** No errors detected Am I doing something wrong? That's a bug. Long story short: please report it to the library maintainers. Indeed, the

Running Boost unit tests on different processes

百般思念 提交于 2019-12-04 07:07:56
I want to do unit testing in a SystemC program. The idea is to have multiple test suites with several tests in each suite. Each one of the tests would require resetting the SystemC framework (e.g., by calling sc_simcontext::reset() ), but that is actually not possible due to some bug that is apparently not going to be fixed anytime soon. Therefore, I decided to come up with a workaround. I found out that if I run each test on a different process everything works fine. The following code snippet gives an overview of the scheme I used to make it work: void test1() { // ... sc_start(); } void