xtd - Reference Guide  0.1.0
Modern c++17/20 framework to create console, GUI and unit test applications on Windows, macOS, Linux, iOS and android.
Loading...
Searching...
No Matches
Public Member Functions | List of all members
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) {
}
};
}
int main() {
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
int run()
Runs all tests in this UnitTest object and prints the result.
Definition: unit_test.h:44
The tunit namespace contains a unit test library.
Definition: abort_error.h:11

Inherits xtd::tunit::ostream_unit_test.

Public Member Functions

 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.
 
- 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.
 
int list_tests (const std::vector< std::string > &tests) override
 
std::ostream & ostream ()
 Gets the ostream used by this instance.
 
bool parse_arguments (const std::vector< std::string > &args) override
 
void write_help ()
 
- Public Member Functions inherited from xtd::tunit::unit_test
 unit_test (std::unique_ptr< xtd::tunit::event_listener > event_listener) noexcept
 
 unit_test (std::unique_ptr< xtd::tunit::event_listener > event_listener, int argc, char *argv[]) noexcept
 
size_t aborted_test_count () const noexcept
 
std::vector< std::string > aborted_test_names () const noexcept
 
std::chrono::milliseconds elapsed_time () const noexcept
 
size_t failed_test_count () const noexcept
 
std::vector< std::string > failed_test_names () const noexcept
 
size_t ignored_test_count () const noexcept
 
std::vector< std::string > ignored_test_names () const noexcept
 
int repeat_iteration () const noexcept
 
int repeat_iteration_count () const noexcept
 
bool repeat_tests () const noexcept
 
int run ()
 Runs all tests in this UnitTest object and prints the result.
 
size_t succeed_test_count () const noexcept
 
std::vector< std::string > succeed_test_names () const noexcept
 
size_t test_cases_count () const noexcept
 
size_t test_count () const noexcept
 

Additional Inherited Members

virtual int list_tests (const std::vector< std::string > &tests)
 
virtual bool parse_arguments (const std::vector< std::string > &args)
 

Constructor & Destructor Documentation

◆ console_unit_test() [1/2]

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

Create a new console unit test.

◆ console_unit_test() [2/2]

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

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: