xtd 0.2.0
xtd::tunit::console_unit_test Class Referencefinal

#include <console_unit_test.h>

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) {
public:
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)
Examples:
all_items_are_instances_of.cpp, all_items_are_not_null.cpp, 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_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_NaN.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, class_with_insert_stream_operator.cpp, class_without_insert_stream_operator.cpp, console_unit_test.cpp, hello_world_tunit.cpp, many_asserts.cpp, many_valids_and_asserts.cpp, math_assert.cpp, string_assert_are_equal_ignoring_case.cpp, string_assert_are_not_equal_ignoring_case.cpp, string_assert_contains.cpp, test_class.cpp, and test_class_without_helpers.cpp.

Constructors

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

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. More...
 
 ostream_unit_test (std::ostream &os, int argc, char *argv[])
 Create a new console unit test with ostream specified, argv specified and argc specified. More...
 
std::ostream & ostream ()
 Gets the ostream used by this instance. More...
 
int list_tests (const std::vector< std::string > &tests) override
 Lists the test names contained in the specified tests. More...
 
bool parse_arguments (const std::vector< std::string > &args) override
 Parses the specified arguments. More...
 
void write_help ()
 Write usage help on the ostream of this instance. More...
 
- 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. More...
 
 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. More...
 
int32 repeat_iteration () const noexcept
 Gets the repeat iteration number. A number between 0 and xtd::tunit::unit_test::repeat_iteration_count. More...
 
int32 repeat_iteration_count () const noexcept
 Gets the repeat iteration count. More...
 
bool repeat_tests () const noexcept
 Gets a boolean indictaes if there is repeat tests. More...
 
size_t test_cases_count () const noexcept
 Gets the test cases count. More...
 
size_t test_count () const noexcept
 Gets the test count. More...
 
size_t aborted_test_count () const noexcept
 Gets the aborted test count. More...
 
std::vector< std::string > aborted_test_names () const noexcept
 Gets the array of aborted test names. More...
 
std::chrono::milliseconds elapsed_time () const noexcept
 Gets the elapsed time for the execution of all tests in the unit test. More...
 
size_t ignored_test_count () const noexcept
 Gets the ignored test count. More...
 
std::vector< std::string > ignored_test_names () const noexcept
 Gets the array of ignored test names. More...
 
size_t failed_test_count () const noexcept
 Gets the failed test count. More...
 
std::vector< std::string > failed_test_names () const noexcept
 Gets the array of failed test names. More...
 
size_t succeed_test_count () const noexcept
 Gets the succeed test count. More...
 
std::vector< std::string > succeed_test_names () const noexcept
 Gets the array of succeed test names. More...
 
int32 run ()
 Runs all tests in this unit_test object and prints the result. More...
 
- 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: