xtd 1.0.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.

Public Properties

auto repeat_iteration () const noexcept -> xtd::int32
 Gets the repeat iteration number. A number between 0 and xtd::tunit::unit_test::repeat_iteration_count.
auto repeat_iteration_count () const noexcept -> xtd::int32
 Gets the repeat iteration count.
auto repeat_tests () const noexcept -> bool
 Gets a boolean indictaes if there is repeat tests.
auto test_cases_count () const noexcept -> xtd::usize
 Gets the test cases count.
auto test_count () const noexcept -> xtd::usize
 Gets the test count.
auto aborted_test_count () const noexcept -> xtd::usize
 Gets the aborted test count.
auto aborted_test_names () const noexcept -> xtd::array< xtd::string >
 Gets the array of aborted test names.
auto elapsed_time () const noexcept -> xtd::time_span
 Gets the elapsed time for the execution of all tests in the unit test.
auto ignored_test_count () const noexcept -> xtd::usize
 Gets the ignored test count.
auto ignored_test_names () const noexcept -> xtd::array< xtd::string >
 Gets the array of ignored test names.
auto failed_test_count () const noexcept -> xtd::usize
 Gets the failed test count.
auto failed_test_names () const noexcept -> xtd::array< xtd::string >
 Gets the array of failed test names.
auto succeed_test_count () const noexcept -> xtd::usize
 Gets the succeed test count.
auto succeed_test_names () const noexcept -> xtd::array< xtd::string >
 Gets the array of succeed test names.

Public Methods

auto run () noexcept -> xtd::int32
 Runs all tests in this unit_test object and prints the result.

Protected Methods

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

Constructor & Destructor Documentation

◆ unit_test()

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 done with xtd::environment::get_command_line_args method.

Member Function Documentation

◆ repeat_iteration()

auto xtd::tunit::unit_test::repeat_iteration ( ) const -> xtd::int32
nodiscardnoexcept

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()

auto xtd::tunit::unit_test::repeat_iteration_count ( ) const -> xtd::int32
nodiscardnoexcept

Gets the repeat iteration count.

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

◆ repeat_tests()

auto xtd::tunit::unit_test::repeat_tests ( ) const -> bool
nodiscardnoexcept

Gets a boolean indictaes if there is repeat tests.

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

◆ test_cases_count()

auto xtd::tunit::unit_test::test_cases_count ( ) const -> xtd::usize
nodiscardnoexcept

Gets the test cases count.

Returns
The test cases count.

◆ test_count()

auto xtd::tunit::unit_test::test_count ( ) const -> xtd::usize
nodiscardnoexcept

Gets the test count.

Returns
The test count.

◆ aborted_test_count()

auto xtd::tunit::unit_test::aborted_test_count ( ) const -> xtd::usize
nodiscardnoexcept

Gets the aborted test count.

Returns
The aborted test count.

◆ aborted_test_names()

auto xtd::tunit::unit_test::aborted_test_names ( ) const -> xtd::array< xtd::string >
nodiscardnoexcept

Gets the array of aborted test names.

Returns
The array of aborted test names.

◆ elapsed_time()

auto xtd::tunit::unit_test::elapsed_time ( ) const -> xtd::time_span
nodiscardnoexcept

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()

auto xtd::tunit::unit_test::ignored_test_count ( ) const -> xtd::usize
nodiscardnoexcept

Gets the ignored test count.

Returns
The ignored test count.

◆ ignored_test_names()

auto xtd::tunit::unit_test::ignored_test_names ( ) const -> xtd::array< xtd::string >
nodiscardnoexcept

Gets the array of ignored test names.

Returns
The array of ignored test names.

◆ failed_test_count()

auto xtd::tunit::unit_test::failed_test_count ( ) const -> xtd::usize
nodiscardnoexcept

Gets the failed test count.

Returns
The failed test count.

◆ failed_test_names()

auto xtd::tunit::unit_test::failed_test_names ( ) const -> xtd::array< xtd::string >
nodiscardnoexcept

Gets the array of failed test names.

Returns
The array of failed test names.

◆ succeed_test_count()

auto xtd::tunit::unit_test::succeed_test_count ( ) const -> xtd::usize
nodiscardnoexcept

Gets the succeed test count.

Returns
The succeed test count.

◆ succeed_test_names()

auto xtd::tunit::unit_test::succeed_test_names ( ) const -> xtd::array< xtd::string >
nodiscardnoexcept

Gets the array of succeed test names.

Returns
The array of succeed test names.

◆ run()

auto xtd::tunit::unit_test::run ( ) -> xtd::int32
noexcept

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

Returns
EXIT_SUCCESS (0) if succeed; otherwise return EXIT_FAILURE (1).

◆ count_tests()

virtual auto xtd::tunit::unit_test::count_tests ( xtd::int32 count) -> xtd::int32
nodiscardprotectedvirtual

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 auto xtd::tunit::unit_test::list_tests ( const xtd::array< xtd::string > & tests) -> xtd::int32
nodiscardprotectedvirtual

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 auto xtd::tunit::unit_test::parse_arguments ( const xtd::array< string > & args) -> bool
nodiscardprotectedvirtual

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: