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/date_time>
11#include <xtd/string>
12
14namespace xtd {
16 namespace tunit {
18 template<class test_class_t>
21
30 public:
32
38
45
47 virtual ~unit_test();
49
51
55 int32 repeat_iteration() const noexcept;
56
60 int32 repeat_iteration_count() const noexcept;
61
65 bool repeat_tests() const noexcept;
66
69 size_t test_cases_count() const noexcept;
70
73 size_t test_count() const noexcept;
74
77 size_t aborted_test_count() const noexcept;
78
81 xtd::array<xtd::string> aborted_test_names() const noexcept;
82
85 xtd::time_span elapsed_time() const noexcept;
86
89 size_t ignored_test_count() const noexcept;
90
93 xtd::array<xtd::string> ignored_test_names() const noexcept;
94
97 size_t failed_test_count() const noexcept;
98
101 xtd::array<xtd::string> failed_test_names() const noexcept;
102
105 size_t succeed_test_count() const noexcept;
106
109 xtd::array<xtd::string> succeed_test_names() const noexcept;
111
112
114
118 int32 run() noexcept;
120
121
122 protected:
124
131 virtual int32 count_tests(int32 count);
132
138 virtual int32 list_tests(const xtd::array<xtd::string>& tests);
139
144 virtual bool parse_arguments(const xtd::array<string>& args);
146
147 private:
148 template<class test_class_t>
149 friend class xtd::tunit::test_class_attribute;
150 friend class xtd::tunit::test_class;
151 friend class xtd::tunit::test;
152 friend class xtd::tunit::base_assert;
153
154 static void add(const xtd::tunit::registered_test_class& test_class);
155 static xtd::collections::generic::list<xtd::tunit::registered_test_class>& test_classes();
156 xtd::string get_filename(const xtd::string& path);
157 xtd::string cdata_message_to_xml_string(const xtd::tunit::test& test);
158 xtd::string escape_path_to_json_string(const xtd::string& path);
159 xtd::string escape_to_json_string(const xtd::string& str);
160 xtd::string escape_to_xml_string(const xtd::string& str);
161 xtd::string message_to_json_string(const xtd::tunit::test& test);
162 xtd::string message_to_xml_string(const xtd::tunit::test& test);
163 xtd::string name_to_string(const xtd::string& name);
164 xtd::string status_to_string(const xtd::tunit::test& test);
165 xtd::string to_string(const time_span& ms);
166 void unit_test_cleanup();
167 void unit_test_initialize();
168 void write_list_tests_json();
169 void write_list_tests_xml();
170 void write_tests_json();
171 void write_tests_xml();
172
173 xtd::array<string> arguments;
174 xtd::string name_ = "AllTests";
175 xtd::uptr<xtd::tunit::event_listener> event_listener_;
176 xtd::date_time end_time_point_;
177 int32 repeat_iteration_ = 0;
178 xtd::date_time start_time_point_;
179 };
180 }
181}
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...
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,...
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.