xtd 0.2.0
settings.hpp
Go to the documentation of this file.
1
4#pragma once
5#include "../tunit_export.hpp"
6#include <xtd/reflection/assembly>
7#include <xtd/io/path>
8#include <xtd/date_time>
9#include <xtd/string>
10#include <cstdint>
11#include <cstdlib>
12#include <xtd/optional>
13
15namespace xtd {
17 namespace tunit {
21 class unit_test;
23
30 class tunit_export_ settings final {
31 public:
33
59 settings() = default;
61
63 settings(const settings&) = default;
64 settings& operator =(const settings&) = default;
66
68
72 bool also_run_ignored_tests() const noexcept;
73
77
80 bool break_on_failure() const noexcept;
81
85
88 bool brief() const noexcept;
89
92 void brief(bool brief) noexcept;
93
96 bool count_tests() const noexcept;
97
100 void count_tests(bool count_tests) noexcept;
101
105 bool enable_stack_trace() const noexcept;
106
111
114 const xtd::date_time& end_time() const noexcept;
115
119 int32 exit_status() const noexcept;
120
125
128 const xtd::array<string>& filter_tests() const noexcept;
129
132 void filter_tests(const xtd::array<string>& filter_tests) noexcept;
133
136 bool gtest_compatibility() const noexcept;
137
141
144 bool is_match_test_name(const xtd::string& test_class_name, const xtd::string& test_name) const noexcept;
145
148 bool list_tests() const noexcept;
149
152 void list_tests(bool list_tests) noexcept;
153
156 bool output_color() const noexcept;
157
160 void output_color(bool output_color) noexcept;
161
164 bool output_json() const noexcept;
165
168 void output_json(bool output_json) noexcept;
169
172 xtd::string output_json_path() const noexcept;
173
176 void output_json_path(const xtd::string& output_json_path) noexcept;
177
180 bool output_xml() const noexcept;
181
184 void output_xml(bool output_xml) noexcept;
185
188 xtd::string output_xml_path() const noexcept;
189
192 void output_xml_path(const xtd::string& output_xml_path) noexcept;
193
196 uint32 random_seed() const noexcept;
197
201
204 int32 repeat_test() const noexcept;
205
209
212 bool show_duration() const noexcept;
213
216 void show_duration(bool show_duration) noexcept;
217
220 bool shuffle_test() const noexcept;
221
224 void shuffle_test(bool shuffle_test) noexcept;
225
228 const xtd::date_time& start_time() const noexcept;
229
232 bool throw_on_failure() const noexcept;
233
238
240
267 static xtd::tunit::settings& default_settings() noexcept;
269
270 private:
271 friend class xtd::tunit::ostream_event_listener;
272 friend class xtd::tunit::ostream_unit_test;
273 friend class xtd::tunit::unit_test;
274
275 void end_time(const xtd::date_time& end_time) noexcept;
276 void start_time(const xtd::date_time& start_time) noexcept;
277
278 bool also_run_ignored_tests_ = false;
279 bool break_on_failure_ = false;
280 bool brief_ = false;
281 bool count_tests_ = false;
282 bool enable_stack_trace_ = false;
283 xtd::date_time end_time_;
284 int32 exit_status_ = EXIT_SUCCESS;
285 xtd::string file_name_ = xtd::io::path::get_full_path(xtd::reflection::assembly::get_executing_assembly().location());
286 xtd::array<string> filter_tests_ = {"*.*"};
287 bool gtest_compatibility_ = false;
288 bool list_tests_ = false;
289 bool output_color_ = true;
290 bool output_json_ = false;
291 std::optional<xtd::string> output_json_path_;
292 bool output_xml_ = false;
293 std::optional<xtd::string> output_xml_path_;
294 uint32 random_seed_ = 0;
295 int32 repeat_tests_ = 1;
296 bool show_duration_ = true;
297 bool shuffle_tests_ = false;
298 xtd::date_time start_time_;
299 bool throw_on_failure_ = false;
300 };
301 }
302}
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
The ostream_unit_test class is a specialisation of event_listener class for writing events in std::os...
Definition ostream_event_listener.hpp:23
The ostream_unit_test class is ostream unit test interface.
Definition ostream_unit_test.hpp:22
int32 exit_status() const noexcept
Gets exit status.
bool brief() const noexcept
Gets brief.
int32 repeat_test() const noexcept
Gets repeat tests count.
const xtd::date_time & end_time() const noexcept
Gets unit test end time.
bool break_on_failure() const noexcept
Gets break immediatly on failure.
xtd::string output_json_path() const noexcept
Gets output json path.
bool also_run_ignored_tests() const noexcept
Gets also run ignored test.
bool shuffle_test() const noexcept
Gets shuffle tests.
settings()=default
Creates new instance of settings.
bool output_xml() const noexcept
Gets output xml.
uint32 random_seed() const noexcept
Gets random seed value.
bool show_duration() const noexcept
Gets if show duration for each test.
static xtd::tunit::settings & default_settings() noexcept
Gets default settings instance.
bool output_color() const noexcept
Gets output color.
void repeat_tests(int32 repeat_tests) noexcept
Sets repeat tests count.
bool is_match_test_name(const xtd::string &test_class_name, const xtd::string &test_name) const noexcept
Return true if a specified test class name and specified test name match with the current filter test...
xtd::string output_xml_path() const noexcept
Gets output xml path.
bool enable_stack_trace() const noexcept
Gets stack trace enabled.
bool throw_on_failure() const noexcept
Gets throw on failure.
const xtd::array< string > & filter_tests() const noexcept
Gets filter tests.
bool output_json() const noexcept
Gets output xml.
const xtd::date_time & start_time() const noexcept
Gets unit test start time.
bool count_tests() const noexcept
Gets count tests.
bool gtest_compatibility() const noexcept
Gets google test comaptibility.
bool list_tests() const noexcept
Gets list tests.
The unit_test class is unit test base interface.
Definition unit_test.hpp:29
#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
uint32_t uint32
Represents a 32-bit unsigned integer.
Definition uint32.hpp:23
@ path
The xtd::uri::local_path data.
Definition uri_components.hpp:27
The xtd::io namespace contains types that allow reading and writing to files and data streams,...
Definition binary_reader.hpp:17
The xtd::reflection namespace contains types that retrieve information about assemblies,...
Definition assembly.hpp:11
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 tunit_export_ keyword.