xtd 1.0.0
Loading...
Searching...
No Matches
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<typename test_class_t>
22
31 public:
33
40
42 virtual ~unit_test();
44
46
50 [[nodiscard]] auto repeat_iteration() const noexcept -> xtd::int32;
51
55 [[nodiscard]] auto repeat_iteration_count() const noexcept -> xtd::int32;
56
60 [[nodiscard]] auto repeat_tests() const noexcept -> bool;
61
64 [[nodiscard]] auto test_cases_count() const noexcept -> xtd::usize;
65
68 [[nodiscard]] auto test_count() const noexcept -> xtd::usize;
69
72 [[nodiscard]] auto aborted_test_count() const noexcept -> xtd::usize;
73
76 [[nodiscard]] auto aborted_test_names() const noexcept -> xtd::array<xtd::string>;
77
80 [[nodiscard]] auto elapsed_time() const noexcept -> xtd::time_span;
81
84 [[nodiscard]] auto ignored_test_count() const noexcept -> xtd::usize;
85
88 [[nodiscard]] auto ignored_test_names() const noexcept -> xtd::array<xtd::string>;
89
92 [[nodiscard]] auto failed_test_count() const noexcept -> xtd::usize;
93
96 [[nodiscard]] auto failed_test_names() const noexcept -> xtd::array<xtd::string>;
97
100 [[nodiscard]] auto succeed_test_count() const noexcept -> xtd::usize;
101
104 [[nodiscard]] auto succeed_test_names() const noexcept -> xtd::array<xtd::string>;
106
108
112 auto run() noexcept -> xtd::int32;
114
115
116 protected:
118
125 [[nodiscard]] virtual auto count_tests(xtd::int32 count) -> xtd::int32;
126
132 [[nodiscard]] virtual auto list_tests(const xtd::array<xtd::string>& tests) -> xtd::int32;
133
138 [[nodiscard]] virtual auto parse_arguments(const xtd::array<string>& args) -> bool;
140
141 private:
142 template<typename test_class_t>
143 friend class xtd::tunit::test_class_attribute;
144 friend class xtd::tunit::test_class;
145 friend class xtd::tunit::test;
146 friend class xtd::tunit::base_assert;
147
148 static auto add(const xtd::tunit::registered_test_class& test_class) -> void;
149 [[nodiscard]] static xtd::collections::generic::list<xtd::tunit::registered_test_class>& test_classes();
150 [[nodiscard]] auto get_filename(const xtd::string& path) -> xtd::string;
151 [[nodiscard]] auto cdata_message_to_xml_string(const xtd::tunit::test& test) -> xtd::string;
152 [[nodiscard]] auto escape_path_to_json_string(const xtd::string& path) -> xtd::string;
153 [[nodiscard]] auto escape_to_json_string(const xtd::string& str) -> xtd::string;
154 [[nodiscard]] auto escape_to_xml_string(const xtd::string& str) -> xtd::string;
155 [[nodiscard]] auto message_to_json_string(const xtd::tunit::test& test) -> xtd::string;
156 [[nodiscard]] auto message_to_xml_string(const xtd::tunit::test& test) -> xtd::string;
157 [[nodiscard]] auto name_to_string(const xtd::string& name) -> xtd::string;
158 [[nodiscard]] auto status_to_string(const xtd::tunit::test& test) -> xtd::string;
159 [[nodiscard]] auto to_string(const time_span& ms) -> xtd::string;
160 auto unit_test_cleanup() -> void;
161 auto unit_test_initialize() -> void;
162 auto write_list_tests_json() -> void;
163 auto write_list_tests_xml() -> void;
164 auto write_tests_json() -> void;
165 auto write_tests_xml() -> void;
166
167 xtd::array<string> arguments;
168 xtd::string name_ = "AllTests";
169 xtd::uptr<xtd::tunit::event_listener> event_listener_;
170 xtd::date_time end_time_point_;
171 int32 repeat_iteration_ = 0;
172 xtd::date_time start_time_point_;
173 };
174 }
175}
Provides methods for creating, manipulating, searching, and sorting arrays, thereby serving as the ba...
Definition array.hpp:64
Represents an instant in time, typically expressed as a date and time of day.
Definition date_time.hpp:83
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
auto ignored_test_names() const noexcept -> xtd::array< xtd::string >
Gets the array of ignored test names.
auto succeed_test_count() const noexcept -> xtd::usize
Gets the succeed test count.
auto repeat_tests() const noexcept -> bool
Gets a boolean indictaes if there is repeat tests.
auto elapsed_time() const noexcept -> xtd::time_span
Gets the elapsed time for the execution of all tests in the unit test.
virtual auto list_tests(const xtd::array< xtd::string > &tests) -> xtd::int32
Lists the test names contained in the specified tests.
auto succeed_test_names() const noexcept -> xtd::array< xtd::string >
Gets the array of succeed test names.
auto failed_test_names() const noexcept -> xtd::array< xtd::string >
Gets the array of failed test names.
auto test_cases_count() const noexcept -> xtd::usize
Gets the test cases count.
auto run() noexcept -> xtd::int32
Runs all tests in this unit_test object and prints the result.
auto test_count() const noexcept -> xtd::usize
Gets the test count.
auto repeat_iteration_count() const noexcept -> xtd::int32
Gets the repeat iteration count.
auto aborted_test_count() const noexcept -> xtd::usize
Gets the aborted test count.
auto failed_test_count() const noexcept -> xtd::usize
Gets the failed test count.
virtual auto count_tests(xtd::int32 count) -> xtd::int32
Counts the test names contained in the specified tests.
virtual auto parse_arguments(const xtd::array< string > &args) -> bool
Parses the specified arguments.
auto repeat_iteration() const noexcept -> xtd::int32
Gets the repeat iteration number. A number between 0 and xtd::tunit::unit_test::repeat_iteration_coun...
auto aborted_test_names() const noexcept -> xtd::array< xtd::string >
Gets the array of aborted test names.
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.
auto ignored_test_count() const noexcept -> xtd::usize
Gets the ignored test count.
Contains xtd::tunit::event_listener class.
#define tunit_export_
Define shared library export.
Definition tunit_export.hpp:13
xtd::unique_ptr_object< type_t > uptr
The xtd::uptr object is a unique pointer.
Definition uptr.hpp:25
std::int32_t int32
Represents a 32-bit signed integer.
Definition int32.hpp:25
std::size_t usize
Represents an unsigned size of any object in bytes.
Definition usize.hpp:22
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.