xtd 0.2.0
Loading...
Searching...
No Matches
xtd::tunit::console_unit_test Class Referencefinal
Inheritance diagram for xtd::tunit::console_unit_test:
xtd::tunit::ostream_unit_test xtd::tunit::unit_test

Definition

The console_unit_test class is console unit test interface.

Namespace
xtd::tunit
Library
xtd.tunit
Remarks
All messages are displayed on the console.
Examples
This example shows how to instantiate and launch tests with console unit test.
#include <xtd/xtd.tunit>
#include <sstream>
using namespace std;
using namespace xtd::tunit;
namespace unit_tests {
class test_class_(test) {
void test_method_(test_case1) {
}
};
}
auto main()->int {
return console_unit_test().run();
// is same :
// return unit_test(std::make_unique<ostream_event_listener>(cout)).run();
}
// This code can produce the following output:
//
// Start 1 test from 1 test case
// Run tests:
// SUCCEED test.test_case1 (0 ms total)
//
// Test results:
// SUCCEED 1 test.
// End 1 test 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()
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
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, 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, hello_world_tunit.cpp, hello_world_tunit_without_helpers.cpp, many_asserts.cpp, many_valids_and_asserts.cpp, math_assert.cpp, math_assume.cpp, math_valid.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, test_class_without_helpers.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.

Public Constructors

 console_unit_test ()
 Create a new console unit test.
 
 console_unit_test (int argc, char *argv[])
 Create a new console unit test with argv specified and argc specified.
 

Additional Inherited Members

- Public Member Functions inherited from xtd::tunit::ostream_unit_test
 ostream_unit_test (std::ostream &os) noexcept
 Create a new console unit test with ostream specified.
 
 ostream_unit_test (std::ostream &os, int argc, char *argv[])
 Create a new console unit test with ostream specified, argv specified and argc specified.
 
std::ostream & ostream ()
 Gets the ostream used by this instance.
 
int count_tests (int32 count) override
 Counts the test names contained in the specified tests.
 
int list_tests (const std::vector< xtd::ustring > &tests) override
 Lists the test names contained in the specified tests.
 
bool parse_arguments (const std::vector< xtd::ustring > &args) override
 Parses the specified arguments.
 
void write_help ()
 Write usage help on the ostream of this instance.
 
- Public Member Functions inherited from xtd::tunit::unit_test
 unit_test (std::unique_ptr< xtd::tunit::event_listener > event_listener) noexcept
 Initializes a new instance of xtd::tunit::unit_test with specified xtd::tunit::event_listener.
 
 unit_test (std::unique_ptr< xtd::tunit::event_listener > event_listener, int argc, char *argv[]) noexcept
 Initializes a new instance of xtd::tunit::unit_test with specified xtd::tunit::event_listener, argument counts and arguments array.
 
int32 repeat_iteration () const noexcept
 Gets the repeat iteration number. A number between 0 and xtd::tunit::unit_test::repeat_iteration_count.
 
int32 repeat_iteration_count () const noexcept
 Gets the repeat iteration count.
 
bool repeat_tests () const noexcept
 Gets a boolean indictaes if there is repeat tests.
 
size_t test_cases_count () const noexcept
 Gets the test cases count.
 
size_t test_count () const noexcept
 Gets the test count.
 
size_t aborted_test_count () const noexcept
 Gets the aborted test count.
 
std::vector< xtd::ustringaborted_test_names () const noexcept
 Gets the array of aborted test names.
 
xtd::time_span elapsed_time () const noexcept
 Gets the elapsed time for the execution of all tests in the unit test.
 
size_t ignored_test_count () const noexcept
 Gets the ignored test count.
 
std::vector< xtd::ustringignored_test_names () const noexcept
 Gets the array of ignored test names.
 
size_t failed_test_count () const noexcept
 Gets the failed test count.
 
std::vector< xtd::ustringfailed_test_names () const noexcept
 Gets the array of failed test names.
 
size_t succeed_test_count () const noexcept
 Gets the succeed test count.
 
std::vector< xtd::ustringsucceed_test_names () const noexcept
 Gets the array of succeed test names.
 
int32 run ()
 Runs all tests in this unit_test object and prints the result.
 
- Protected Member Functions inherited from xtd::tunit::unit_test

Constructor & Destructor Documentation

◆ console_unit_test() [1/2]

xtd::tunit::console_unit_test::console_unit_test ( )

Create a new console unit test.

◆ console_unit_test() [2/2]

xtd::tunit::console_unit_test::console_unit_test ( int  argc,
char *  argv[] 
)

Create a new console unit test with argv specified and argc specified.

Parameters
argcArgument count from main method.
argvArguments array from main method.

The documentation for this class was generated from the following file: