appendFixture() method from fcf::NTest::Storage class
Class:
Package: fcfTest
File: test.hpp
Available from version: 1.2.2
Registers a new test fixture into the global storage.
The
This method is typically used via the
Arguments
- The fcf::NTest::Fixture object containing the setup/teardown function and its scope (level, parts, groups, etc.).
Example: Manual Fixture Registration
Demonstrating how to manually register a global setup/teardown fixture.
#define FCF_TEST_IMPLEMENTATION
#include <fcfTest/test.hpp>
#include <iostream>
void mySetup() {
fcf::NTest::log () << "Manual Setup Executed" << std::endl;
}
FCF_TEST_DEFINE ("Manual", "Demo", "Test") {
FCF_TEST (true);
}
int main(int a_argc, char* a_argv[]) {
bool error = false;
fcf::NTest::Storage & storage = fcf::NTest::storage ();
// 1. Create a Fixture object manually
fcf::NTest::Fixture manualFixture;
manualFixture.parts = {"*"};
manualFixture.groups = {"*"};
manualFixture.tests = {"*"};
manualFixture.before = true;
manualFixture.level = fcf::NTest::FL_GLOBAL ;
manualFixture.fixtureFunction = mySetup;
manualFixture.file = __FILE__;
manualFixture.line = 5;
// 2. Append it to storage
storage.appendFixture (manualFixture);
// 3. Run the tests
fcf::NTest::cmdRun (a_argc, a_argv, fcf::NTest::CRM_RUN , &error);
return error ? 1 : 0;
}
Output:
> Manual Setup Executed
Performing the test: "Manual" -> "Demo" -> "Test" ...
[SUCCESS] Test completed successfully (0.000`000`782 sec)
[SUCCESS] All tests were completed.
Tests: 1 passed, 0 failed, 0 skipped, 1 total
Duration: 0.000`000`782 sec
VPSDime is an industry leading VPS hosting company that provides virtualized server services with high performance, availability and friendly support.