xtd 0.2.0
Loading...
Searching...
No Matches
unit_test.h
Go to the documentation of this file.
1
4#pragma once
5#include "../tunit_export.h"
6#include "event_listener.h"
8#include "settings.h"
9#include <xtd/date_time>
10#include <xtd/string>
11
13namespace xtd {
15 namespace tunit {
17 template <typename test_class_t>
18 class test_class_attribute;
20
29 public:
31
37
44
46 virtual ~unit_test();
48
50
54 int32 repeat_iteration() const noexcept;
55
59 int32 repeat_iteration_count() const noexcept;
60
64 bool repeat_tests() const noexcept;
65
68 size_t test_cases_count() const noexcept;
69
72 size_t test_count() const noexcept;
73
76 size_t aborted_test_count() const noexcept;
77
80 std::vector<xtd::string> aborted_test_names() const noexcept;
81
84 xtd::time_span elapsed_time() const noexcept;
85
88 size_t ignored_test_count() const noexcept;
89
92 std::vector<xtd::string> ignored_test_names() const noexcept;
93
96 size_t failed_test_count() const noexcept;
97
100 std::vector<xtd::string> failed_test_names() const noexcept;
101
104 size_t succeed_test_count() const noexcept;
105
108 std::vector<xtd::string> succeed_test_names() const noexcept;
110
111
113
117 int32 run() noexcept;
119
120
121 protected:
123
130 virtual int32 count_tests(int32 count);
131
137 virtual int32 list_tests(const std::vector<xtd::string>& tests);
138
143 virtual bool parse_arguments(const std::vector<string>& args);
145
146 private:
147 template <typename test_class_t>
148 friend class xtd::tunit::test_class_attribute;
149 friend class xtd::tunit::test_class;
150 friend class xtd::tunit::test;
151 friend class xtd::tunit::base_assert;
152
153 static void add(const xtd::tunit::registered_test_class& test_class);
154 static std::vector<xtd::tunit::registered_test_class>& test_classes();
155 xtd::string get_filename(const xtd::string& path);
156 xtd::string cdata_message_to_xml_string(const xtd::tunit::test& test);
157 xtd::string escape_path_to_json_string(const xtd::string& path);
158 xtd::string escape_to_json_string(const xtd::string& str);
159 xtd::string escape_to_xml_string(const xtd::string& str);
160 xtd::string message_to_json_string(const xtd::tunit::test& test);
161 xtd::string message_to_xml_string(const xtd::tunit::test& test);
162 xtd::string name_to_string(const xtd::string& name);
163 xtd::string status_to_string(const xtd::tunit::test& test);
164 xtd::string to_string(const time_span& ms);
165 void unit_test_cleanup();
166 void unit_test_initialize();
167 void write_list_tests_json();
168 void write_list_tests_xml();
169 void write_tests_json();
170 void write_tests_xml();
171
172 std::vector<string> arguments;
173 xtd::string name_ = "AllTests";
174 xtd::uptr<xtd::tunit::event_listener> event_listener_;
175 xtd::date_time end_time_point_;
176 int32 repeat_iteration_ = 0;
177 xtd::date_time start_time_point_;
178 };
179 }
180}
Represents an instant in time, typically expressed as a date and time of day.
Definition date_time.h:85
The base class for assert.
Definition base_assert.h:29
Represent the event listener class. Unit test call theses events when unit tests are processing.
Definition event_listener.h:23
Represents the registered test class.
Definition registered_test_class.h:20
Represents a test class attribute.
Definition test_class_attribute.h:24
Represents a test class.
Definition test_class.h:39
Represents a test method.
Definition test.h:29
The unit_test class is unit test base interface.
Definition unit_test.h:28
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,...
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.
Contains xtd::tunit::event_listener class.
#define tunit_export_
Define shared library export.
Definition tunit_export.h:13
int32_t int32
Represents a 32-bit signed integer.
Definition int32.h:23
std::unique_ptr< type_t > uptr
The xtd::uptr object is a unique pointer.
Definition uptr.h:25
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.h:10
Contains xtd::tunit::registered_test_class class.
Represents a time interval.
Definition time_span.h:29
Contains xtd::tunit::settings class.