xtd 0.2.0
unit_test.hpp
Go to the documentation of this file.
1
4#pragma once
5#include "../tunit_export.hpp"
6#include "event_listener.hpp"
8#include "settings.hpp"
9#include <xtd/collections/generic/list>
10#include <xtd/argument_collection>
11#include <xtd/date_time>
12#include <xtd/string>
13
15namespace xtd {
17 namespace tunit {
19 template<class test_class_t>
22
31 public:
33
40
42 virtual ~unit_test();
44
46
50 int32 repeat_iteration() const noexcept;
51
55 int32 repeat_iteration_count() const noexcept;
56
60 bool repeat_tests() const noexcept;
61
64 size_t test_cases_count() const noexcept;
65
68 size_t test_count() const noexcept;
69
72 size_t aborted_test_count() const noexcept;
73
76 xtd::array<xtd::string> aborted_test_names() const noexcept;
77
80 xtd::time_span elapsed_time() const noexcept;
81
84 size_t ignored_test_count() const noexcept;
85
88 xtd::array<xtd::string> ignored_test_names() const noexcept;
89
92 size_t failed_test_count() const noexcept;
93
96 xtd::array<xtd::string> failed_test_names() const noexcept;
97
100 size_t succeed_test_count() const noexcept;
101
104 xtd::array<xtd::string> succeed_test_names() const noexcept;
106
107
109
113 int32 run() noexcept;
115
116
117 protected:
119
126 virtual int32 count_tests(int32 count);
127
133 virtual int32 list_tests(const xtd::array<xtd::string>& tests);
134
139 virtual bool parse_arguments(const xtd::array<string>& args);
141
142 private:
143 template<class test_class_t>
144 friend class xtd::tunit::test_class_attribute;
145 friend class xtd::tunit::test_class;
146 friend class xtd::tunit::test;
147 friend class xtd::tunit::base_assert;
148
149 static void add(const xtd::tunit::registered_test_class& test_class);
150 static xtd::collections::generic::list<xtd::tunit::registered_test_class>& test_classes();
151 xtd::string get_filename(const xtd::string& path);
152 xtd::string cdata_message_to_xml_string(const xtd::tunit::test& test);
153 xtd::string escape_path_to_json_string(const xtd::string& path);
154 xtd::string escape_to_json_string(const xtd::string& str);
155 xtd::string escape_to_xml_string(const xtd::string& str);
156 xtd::string message_to_json_string(const xtd::tunit::test& test);
157 xtd::string message_to_xml_string(const xtd::tunit::test& test);
158 xtd::string name_to_string(const xtd::string& name);
159 xtd::string status_to_string(const xtd::tunit::test& test);
160 xtd::string to_string(const time_span& ms);
161 void unit_test_cleanup();
162 void unit_test_initialize();
163 void write_list_tests_json();
164 void write_list_tests_xml();
165 void write_tests_json();
166 void write_tests_xml();
167
168 xtd::array<string> arguments;
169 xtd::string name_ = "AllTests";
170 xtd::uptr<xtd::tunit::event_listener> event_listener_;
171 xtd::date_time end_time_point_;
172 int32 repeat_iteration_ = 0;
173 xtd::date_time start_time_point_;
174 };
175 }
176}
Provides methods for creating, manipulating, searching, and sorting arrays, thereby serving as the ba...
Definition array.hpp:61
Represents an instant in time, typically expressed as a date and time of day.
Definition date_time.hpp:85
Represents a time interval.
Definition time_span.hpp:29
Represent the event listener class. Unit test call theses events when unit tests are processing.
Definition event_listener.hpp:23
Represents the registered test class.
Definition registered_test_class.hpp:20
Represents a test class attribute.
Definition test_class_attribute.hpp:24
virtual int32 list_tests(const xtd::array< xtd::string > &tests)
Lists the test names contained in the specified tests.
size_t failed_test_count() const noexcept
Gets the failed test count.
size_t test_count() const noexcept
Gets the test count.
xtd::array< xtd::string > ignored_test_names() const noexcept
Gets the array of ignored test names.
xtd::array< xtd::string > aborted_test_names() const noexcept
Gets the array of aborted test names.
int32 repeat_iteration_count() const noexcept
Gets the repeat iteration count.
int32 run() noexcept
Runs all tests in this unit_test object and prints the result.
bool repeat_tests() const noexcept
Gets a boolean indictaes if there is repeat tests.
virtual int32 count_tests(int32 count)
Counts the test names contained in the specified tests.
xtd::array< xtd::string > succeed_test_names() const noexcept
Gets the array of succeed 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 aborted_test_count() const noexcept
Gets the aborted test count.
size_t succeed_test_count() const noexcept
Gets the succeed test count.
int32 repeat_iteration() const noexcept
Gets the repeat iteration number. A number between 0 and xtd::tunit::unit_test::repeat_iteration_coun...
virtual bool parse_arguments(const xtd::array< string > &args)
Parses the specified arguments.
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.
size_t ignored_test_count() const noexcept
Gets the ignored test count.
size_t test_cases_count() const noexcept
Gets the test cases count.
xtd::array< xtd::string > failed_test_names() const noexcept
Gets the array of failed test names.
Contains xtd::tunit::event_listener class.
#define tunit_export_
Define shared library export.
Definition tunit_export.hpp:13
int32_t int32
Represents a 32-bit signed integer.
Definition int32.hpp:23
xtd::unique_ptr_object< type_t > uptr
The xtd::uptr object is a unique pointer.
Definition uptr.hpp:25
@ path
The xtd::uri::local_path data.
Definition uri_components.hpp:27
The xtd::collections namespace contains interfaces and classes that define various collections of obj...
Definition any_pair.hpp:10
The tunit namespace contains a unit test library.
Definition abort_error.hpp:10
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition abstract_object.hpp:8
Contains xtd::tunit::registered_test_class class.
Contains tunit_export_ keyword.
Contains xtd::tunit::settings class.