line from class fcf::NTest::Fixture
Type:
Class:
Package: fcfTest
File: test.hpp
Available from version: 1.2.2
The source line number where the fixture was defined.
The
Similar to the
Example: Pinpointing Fixture Errors
Demonstrating how the
#define FCF_TEST_IMPLEMENTATION
#include <fcfTest/test.hpp>
#include <stdexcept>
// This fixture will fail and throw an exception
void demoSetup() {
fcf::NTest::log () << "Initializing..." << std::endl;
throw std::runtime_error("Critical setup failure!");
}
FCF_TEST_DEFINE ("ErrorDemo", "Fixture", "Test1") {
fcf::NTest::log () << "This test will not run due to fixture error." << std::endl;
FCF_TEST (true);
}
int main(int a_argc, char* a_argv[]) {
// Manually adding a setup fixture
fcf::NTest::Fixture fixture;
fixture.parts .push_back("ErrorDemo");
fixture.groups .push_back("*");
fixture.tests .push_back("*");
fixture.before = true;
fixture.level = fcf::NTest::FL_PART ;
fixture.fixtureFunction = demoSetup;
fixture.file = __FILE__;
fixture.line = 6;
fcf::NTest::storage ().appendFixture (fixture);
bool error = false;
fcf::NTest::cmdRun (a_argc, a_argv, fcf::NTest::CRM_RUN , &error);
return error ? 1 : 0;
}
Output:
> Initializing...
Performing the test: "ErrorDemo" -> "Fixture" -> "Test1" ...
Fixture error [FILE: PATH/main.cpp:6 ]:
Critical setup failure!
[FAILED] Test failed (0.000`000`411 sec)
[FAILED] Testing completed with failures.
Tests: 0 passed, 1 failed, 0 skipped, 1 total
Duration: 0.000`000`411 sec
VPSDime is an industry leading VPS hosting company that provides virtualized server services with high performance, availability and friendly support.