xtd 0.2.0
Loading...
Searching...
No Matches

◆ test_initialize_

#define test_initialize_ (   method_name)

#include <xtd.tunit/include/xtd/tunit/test_initialize_attribute.h>

Helper to create a test initialize method in a test class.

Parameters
method_nameThe name of the test initialize method.
Examples
The following example shows how to use test_initialize_ helper.
#include <xtd/xtd.tunit>
using namespace xtd::tunit;
namespace unit_tests {
// The class test must be declared with test_class_ helper.
class test_class_(test) {
// This method is the method that is called just before the start of all tests. It is called only once.
static void class_initialize_(class_initialize) {
}
// This method is the method that is called just after all the tests are finished. It is called only once.
static void class_cleanup_(class_cleanup) {
}
// This method is the method that is called just before a test method starts. It is called for each test.
static void test_initialize_(test_initialize) {
}
// This method is the method that is called right after a test method is finished. It is called for each test.
static void test_cleanup_(test_cleanup) {
}
void test_method_(test_case1) {
}
void test_method_(test_case2) {
}
void ignore_test_method_(test_case3) {
}
};
}
auto main() -> int {
return console_unit_test().run();
}
// This code can produce the following output :
//
// Start 3 tests from 1 test case
// Run tests:
// SUCCEED unit_tests::test.test_case1 (0 ms total)
// SUCCEED unit_tests::test.test_case2 (0 ms total)
// IGNORED test.test_case3 (0 ms total)
// Test ignored
//
// Test results:
// SUCCEED 2 tests.
// IGNORED 1 test.
// End 3 tests from 1 test case ran. (0 ms total)
The console_unit_test class is console unit test interface.
Definition console_unit_test.h:23
int32 run() noexcept
Runs all tests in this unit_test object and prints the result.
#define test_method_(method_name)
Add test method to class test.
Definition test_method_attribute.h:89
#define class_initialize_(method_name)
add initialize class method to class test.
Definition class_initialize_attribute.h:52
#define test_initialize_(method_name)
Helper to create a test initialize method in a test class.
Definition test_initialize_attribute.h:47
#define class_cleanup_(method_name)
Add class cleanup method to class test.
Definition class_cleanup_attribute.h:52
#define test_cleanup_(method_name)
Helper to create a test cleanup method in a test class.
Definition test_cleanup_attribute.h:51
#define ignore_test_method_(method_name)
Add ignored test method to class test.
Definition test_method_attribute.h:73
The tunit namespace contains a unit test library.
Definition abort_error.h:10
Examples
test_class.cpp.