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

Definition

The unit_test class is unit test base interface.

Remarks
This class can be instantiated or inherited as for example xtd::tunit::ostream_unit_test.
Namespace
xtd::tunit
Library
xtd.tunit
Examples
create_gtest_like_event_listener.cpp.

Public Constructors

 unit_test (xtd::uptr< xtd::tunit::event_listener > event_listener) noexcept
 Initializes a new instance of xtd::tunit::unit_test with specified xtd::tunit::event_listener.
 
 unit_test (xtd::uptr< 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.
 

Public Properties

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::stringaborted_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::stringignored_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::stringfailed_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::stringsucceed_test_names () const noexcept
 Gets the array of succeed test names.
 

Public Methods

int32 run () noexcept
 Runs all tests in this unit_test object and prints the result.
 

Protected Methods

virtual int32 count_tests (int32 count)
 Counts the test names contained in the specified tests.
 
virtual int32 list_tests (const std::vector< xtd::string > &tests)
 Lists the test names contained in the specified tests.
 
virtual bool parse_arguments (const std::vector< string > &args)
 Parses the specified arguments.
 

Constructor & Destructor Documentation

◆ unit_test() [1/2]

xtd::tunit::unit_test::unit_test ( xtd::uptr< xtd::tunit::event_listener event_listener)
explicitnoexcept

Initializes a new instance of xtd::tunit::unit_test with specified xtd::tunit::event_listener.

Parameters
event_listenerThe event listener associate to the unit tests.
Remarks
The arguments of the unit test application are detected automatically.

◆ unit_test() [2/2]

xtd::tunit::unit_test::unit_test ( xtd::uptr< 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.

Parameters
event_listenerThe event listener associate to the unit tests.
argcArgument count from main method.
argvArguments array from main method.

Member Function Documentation

◆ repeat_iteration()

int32 xtd::tunit::unit_test::repeat_iteration ( ) const
noexcept

Gets the repeat iteration number. A number between 0 and xtd::tunit::unit_test::repeat_iteration_count.

Returns
The repeat iteration number.

◆ repeat_iteration_count()

int32 xtd::tunit::unit_test::repeat_iteration_count ( ) const
noexcept

Gets the repeat iteration count.

Returns
The repeat iteration count.
Remarks
Is the xtd::tunit::settings::repeat_test for the current setting.

◆ repeat_tests()

bool xtd::tunit::unit_test::repeat_tests ( ) const
noexcept

Gets a boolean indictaes if there is repeat tests.

Returns
true is repart test; otherwhise false.
Remarks
Returns true if xtd::tunit::unit_test::repeat_test_count greater than 0.

◆ test_cases_count()

size_t xtd::tunit::unit_test::test_cases_count ( ) const
noexcept

Gets the test cases count.

Returns
The test cases count.

◆ test_count()

size_t xtd::tunit::unit_test::test_count ( ) const
noexcept

Gets the test count.

Returns
The test count.

◆ aborted_test_count()

size_t xtd::tunit::unit_test::aborted_test_count ( ) const
noexcept

Gets the aborted test count.

Returns
The aborted test count.

◆ aborted_test_names()

std::vector< xtd::string > xtd::tunit::unit_test::aborted_test_names ( ) const
noexcept

Gets the array of aborted test names.

Returns
The array of aborted test names.

◆ elapsed_time()

xtd::time_span xtd::tunit::unit_test::elapsed_time ( ) const
noexcept

Gets the elapsed time for the execution of all tests in the unit test.

Returns
The elapsed time for the execution of all tests in the unit test.

◆ ignored_test_count()

size_t xtd::tunit::unit_test::ignored_test_count ( ) const
noexcept

Gets the ignored test count.

Returns
The ignored test count.

◆ ignored_test_names()

std::vector< xtd::string > xtd::tunit::unit_test::ignored_test_names ( ) const
noexcept

Gets the array of ignored test names.

Returns
The array of ignored test names.

◆ failed_test_count()

size_t xtd::tunit::unit_test::failed_test_count ( ) const
noexcept

Gets the failed test count.

Returns
The failed test count.

◆ failed_test_names()

std::vector< xtd::string > xtd::tunit::unit_test::failed_test_names ( ) const
noexcept

Gets the array of failed test names.

Returns
The array of failed test names.

◆ succeed_test_count()

size_t xtd::tunit::unit_test::succeed_test_count ( ) const
noexcept

Gets the succeed test count.

Returns
The succeed test count.

◆ succeed_test_names()

std::vector< xtd::string > xtd::tunit::unit_test::succeed_test_names ( ) const
noexcept

Gets the array of succeed test names.

Returns
The array of succeed test names.

◆ run()

int32 xtd::tunit::unit_test::run ( )
noexcept

Runs all tests in this unit_test object and prints the result.

Returns
EXIT_SUCCESS (0) if succeed; otherwise return EXIT_FAILURE (1).
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, 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, 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.

◆ count_tests()

virtual int32 xtd::tunit::unit_test::count_tests ( int32  count)
protectedvirtual

Counts the test names contained in the specified tests.

Parameters
countThe tests count.
Returns
The xtd::tunit::settings::exit_status value.
Remarks
This method does nothing by default. The inheritor must overload this method to act as it wants when the unit_lest is asked for the test list.
This method is typically used to display the list of tests in a stream, or whatever. It depends on the implementation chosen by the inheritor.

Reimplemented in xtd::tunit::ostream_unit_test.

◆ list_tests()

virtual int32 xtd::tunit::unit_test::list_tests ( const std::vector< xtd::string > &  tests)
protectedvirtual

Lists the test names contained in the specified tests.

Parameters
testsThe list of test names.
Returns
The xtd::tunit::settings::exit_status value.
Remarks
This method does nothing by default. The inheritor must overload this method to act as it wants when the unit_lest is asked for the test list.
This method is typically used to display the list of tests in a stream, or whatever. It depends on the implementation chosen by the inheritor.

Reimplemented in xtd::tunit::ostream_unit_test.

◆ parse_arguments()

virtual bool xtd::tunit::unit_test::parse_arguments ( const std::vector< string > &  args)
protectedvirtual

Parses the specified arguments.

Parameters
Thearguments to parse.
Returns
true the execution process stops immediately after the analysis of the arguments; otherwise false the execution process continues its execution.
Remarks
This method can be overloaded by the heirs. It is typically in this method that the heirs can react to their own arguments. Like for example display a helper when the -help argument is passed.

Reimplemented in xtd::tunit::ostream_unit_test.


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