"Ewgenij Sokolovski"
1. Please provide a complete example
#include<iostream>
#include<vector>
#include
#include using std::vector; using std::string;
using namespace boost::unit_test;
void myTestCase(vector<string> arguments) { string a = arguments[0]; }
test_suite* init_unit_test_suite(int argc, char** argv) {
throw "blub"; vector< vector<string> > arguments(1); arguments[0].push_back("haha"); test_suite* test = BOOST_TEST_SUITE("TestSuite"); test->add(BOOST_PARAM_TEST_CASE(&myTestCase,arguments.begin(), arguments.end())); return test; }
In this version I get the message:
Boost.Test internal framework error: unknown reason
But if I insert the throw "blub" into myTestCase-Function instead:
#include<iostream>
#include<vector>
#include
#include using std::vector; using std::string;
using namespace boost::unit_test;
void myTestCase(vector<string> arguments) { string a = arguments[0]; throw "blub"; }
test_suite* init_unit_test_suite(int argc, char** argv) {
vector< vector<string> > arguments(1); arguments[0].push_back("haha"); test_suite* test = BOOST_TEST_SUITE("TestSuite"); test->add(BOOST_PARAM_TEST_CASE(&myTestCase,arguments.begin(), arguments.end())); return test; }
Then the message after executing is:
Running 1 test case... unknown location(0): fatal error in "myTestCase": C string: blub
*** errors detected in test suite "TestSuite"; see standard output for details
So why it doesn't work, if throw is included in the main function?
Yes. At the moment init_unit_test_suite invocation is not guarded. I should probably change this. At the moment you've got 2 options: 1. Use global fixture (1.34.0) instead of init_unit_test_suite 2. use framework::setup_error to report initialization error
And why it is not possible to determine the location of the exception (the line number) when I include it into myTestCase?
Because C++ doesn't provide a way ;). Do you know one? Gennadiy