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

◆ test_method_

#define test_method_ (   method_name)

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

Add test method to class test.

Parameters
method_nameThe test method to add.
Library
xtd.tunit
Examples
The following example shows how to use test_method_ 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
assert.cpp, assert_abort.cpp, assert_are_equal.cpp, assert_are_equal_with_tolerance.cpp, assert_are_not_equal.cpp, assert_are_not_same.cpp, assert_are_same.cpp, assert_contains.cpp, assert_does_not_throw.cpp, assert_fail.cpp, assert_ignore.cpp, assert_is_NaN.cpp, assert_is_empty.cpp, assert_is_false.cpp, assert_is_greater.cpp, assert_is_greater_or_equal.cpp, assert_is_instance_of.cpp, assert_is_less.cpp, assert_is_less_or_equal.cpp, assert_is_negative.cpp, assert_is_not_empty.cpp, assert_is_not_instance_of.cpp, assert_is_not_null.cpp, assert_is_not_zero.cpp, assert_is_null.cpp, assert_is_positive.cpp, assert_is_true.cpp, assert_is_zero.cpp, assert_succeed.cpp, assert_throws.cpp, assert_throws_any.cpp, assume.cpp, assume_are_equal.cpp, assume_are_equal_with_tolerance.cpp, assume_are_not_equal.cpp, assume_are_not_same.cpp, assume_are_same.cpp, assume_contains.cpp, assume_does_not_throw.cpp, assume_is_NaN.cpp, assume_is_empty.cpp, assume_is_false.cpp, assume_is_greater.cpp, assume_is_greater_or_equal.cpp, assume_is_instance_of.cpp, assume_is_less.cpp, assume_is_less_or_equal.cpp, assume_is_negative.cpp, assume_is_not_empty.cpp, assume_is_not_instance_of.cpp, assume_is_not_null.cpp, assume_is_not_zero.cpp, assume_is_null.cpp, assume_is_positive.cpp, assume_is_true.cpp, assume_is_zero.cpp, assume_throws.cpp, assume_throws_any.cpp, class_with_insert_stream_operator.cpp, class_without_insert_stream_operator.cpp, collection_assert.cpp, collection_assert_all_items_are_instances_of.cpp, collection_assert_all_items_are_not_null.cpp, collection_assert_all_items_are_unique.cpp, collection_assert_are_equal.cpp, collection_assert_are_equivalent.cpp, collection_assert_are_not_equal.cpp, collection_assert_are_not_equivalent.cpp, collection_assert_contains.cpp, collection_assert_does_not_contain.cpp, collection_assert_is_empty.cpp, collection_assert_is_not_empty.cpp, collection_assert_is_ordered.cpp, collection_assume.cpp, collection_assume_all_items_are_instances_of.cpp, collection_assume_all_items_are_not_null.cpp, collection_assume_all_items_are_unique.cpp, collection_assume_are_equal.cpp, collection_assume_are_equivalent.cpp, collection_assume_are_not_equal.cpp, collection_assume_are_not_equivalent.cpp, collection_assume_contains.cpp, collection_assume_does_not_contain.cpp, collection_assume_is_empty.cpp, collection_assume_is_not_empty.cpp, collection_assume_is_ordered.cpp, collection_valid.cpp, collection_valid_all_items_are_instances_of.cpp, collection_valid_all_items_are_not_null.cpp, collection_valid_all_items_are_unique.cpp, collection_valid_are_equal.cpp, collection_valid_are_equivalent.cpp, collection_valid_are_not_equal.cpp, collection_valid_are_not_equivalent.cpp, collection_valid_contains.cpp, collection_valid_does_not_contain.cpp, collection_valid_is_empty.cpp, collection_valid_is_not_empty.cpp, collection_valid_is_ordered.cpp, console_unit_test.cpp, create_gtest_like_event_listener.cpp, directory_assert.cpp, directory_assert_are_equal.cpp, directory_assert_are_not_equal.cpp, directory_assert_does_not_exist.cpp, directory_assert_exists.cpp, directory_assume.cpp, directory_assume_are_equal.cpp, directory_assume_are_not_equal.cpp, directory_assume_does_not_exist.cpp, directory_assume_exists.cpp, directory_valid.cpp, directory_valid_are_equal.cpp, directory_valid_are_not_equal.cpp, directory_valid_does_not_exist.cpp, directory_valid_exists.cpp, file_assert.cpp, file_assert_are_equal.cpp, file_assert_are_not_equal.cpp, file_assert_does_not_exist.cpp, file_assert_exists.cpp, file_assume.cpp, file_assume_are_equal.cpp, file_assume_are_not_equal.cpp, file_assume_does_not_exist.cpp, file_assume_exists.cpp, file_valid.cpp, file_valid_are_equal.cpp, file_valid_are_not_equal.cpp, file_valid_does_not_exist.cpp, file_valid_exists.cpp, generic_test_class.cpp, hello_world_tunit.cpp, many_asserts.cpp, many_valids_and_asserts.cpp, math_assert.cpp, math_assume.cpp, math_valid.cpp, ostream_unit_test.cpp, string_assert.cpp, string_assert_are_equal_ignoring_case.cpp, string_assert_are_not_equal_ignoring_case.cpp, string_assert_contains.cpp, string_assert_does_not_contain.cpp, string_assert_does_not_end_with.cpp, string_assert_does_not_match.cpp, string_assert_does_not_start_with.cpp, string_assert_ends_with.cpp, string_assert_matches.cpp, string_assert_starts_with.cpp, string_assume.cpp, string_assume_are_equal_ignoring_case.cpp, string_assume_are_not_equal_ignoring_case.cpp, string_assume_contains.cpp, string_assume_does_not_contain.cpp, string_assume_does_not_end_with.cpp, string_assume_does_not_match.cpp, string_assume_does_not_start_with.cpp, string_assume_ends_with.cpp, string_assume_matches.cpp, string_assume_starts_with.cpp, string_valid.cpp, string_valid_are_equal_ignoring_case.cpp, string_valid_are_not_equal_ignoring_case.cpp, string_valid_contains.cpp, string_valid_does_not_contain.cpp, string_valid_does_not_end_with.cpp, string_valid_does_not_match.cpp, string_valid_does_not_start_with.cpp, string_valid_ends_with.cpp, string_valid_matches.cpp, string_valid_starts_with.cpp, test_class.cpp, tunit_config_main.cpp, valid.cpp, valid_are_equal.cpp, valid_are_equal_with_tolerance.cpp, valid_are_not_equal.cpp, valid_are_not_same.cpp, valid_are_same.cpp, valid_contains.cpp, valid_does_not_throw.cpp, valid_is_NaN.cpp, valid_is_empty.cpp, valid_is_false.cpp, valid_is_greater.cpp, valid_is_greater_or_equal.cpp, valid_is_instance_of.cpp, valid_is_less.cpp, valid_is_less_or_equal.cpp, valid_is_negative.cpp, valid_is_not_empty.cpp, valid_is_not_instance_of.cpp, valid_is_not_null.cpp, valid_is_not_zero.cpp, valid_is_null.cpp, valid_is_positive.cpp, valid_is_true.cpp, valid_is_zero.cpp, valid_throws.cpp, and valid_throws_any.cpp.