xtd 1.0.0
Loading...
Searching...
No Matches
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 <xtd/optional>
12
14namespace xtd {
16 namespace tunit {
20 class unit_test;
22
29 class tunit_export_ settings final {
30 public:
32
58 settings() = default;
60
62
66 [[nodiscard]] auto also_run_ignored_tests() const noexcept -> bool;
69 auto also_run_ignored_tests(bool value) noexcept -> settings&;
70
73 [[nodiscard]] auto break_on_failure() const noexcept -> bool;
76 auto break_on_failure(bool value) noexcept -> settings&;
77
80 [[nodiscard]] auto brief() const noexcept -> bool;
83 auto brief(bool value) noexcept -> settings&;
84
87 [[nodiscard]] auto count_tests() const noexcept -> bool;
90 auto count_tests(bool value) noexcept -> settings&;
91
95 [[nodiscard]] auto enable_stack_trace() const noexcept -> bool;
99 auto enable_stack_trace(bool value) noexcept -> settings&;
100
103 [[nodiscard]] auto end_time() const noexcept -> const xtd::date_time&;
104
108 [[nodiscard]] auto exit_status() const noexcept -> xtd::int32;
112 auto exit_status(xtd::int32 value) noexcept -> settings&;
113
116 [[nodiscard]] auto filter_tests() const noexcept -> const xtd::array<xtd::string>&;
119 auto filter_tests(const xtd::array<xtd::string>& value) noexcept -> settings&;
120
123 [[nodiscard]] auto gtest_compatibility() const noexcept -> bool;
126 auto gtest_compatibility(bool value) noexcept -> settings&;
127
130 [[nodiscard]] auto is_match_test_name(const xtd::string& test_class_name, const xtd::string& test_name) const noexcept -> bool;
131
134 [[nodiscard]] auto list_tests() const noexcept -> bool;
137 auto list_tests(bool value) noexcept -> settings&;
138
141 [[nodiscard]] auto output_color() const noexcept -> bool;
144 auto output_color(bool value) noexcept -> settings&;
145
148 [[nodiscard]] auto output_json() const noexcept -> bool;
151 auto output_json(bool value) noexcept -> settings&;
152
155 [[nodiscard]] auto output_json_path() const noexcept -> xtd::string;
158 auto output_json_path(const xtd::string& value) noexcept -> settings&;
159
162 [[nodiscard]] auto output_xml() const noexcept -> bool;
165 auto output_xml(bool value) noexcept -> settings&;
166
169 [[nodiscard]] auto output_xml_path() const noexcept -> xtd::string;
172 auto output_xml_path(const xtd::string& value) noexcept -> settings&;
173
176 [[nodiscard]] auto random_seed() const noexcept -> xtd::uint32;
179 auto random_seed(xtd::uint32 value) noexcept -> settings&;
180
183 [[nodiscard]] auto repeat_test() const noexcept -> xtd::int32;
186 auto repeat_tests(xtd::int32 value) noexcept -> settings&;
187
190 [[nodiscard]] auto show_duration() const noexcept -> bool;
193 auto show_duration(bool value) noexcept -> settings&;
194
197 [[nodiscard]] auto shuffle_test() const noexcept -> bool;
200 auto shuffle_test(bool value) noexcept -> settings&;
201
204 [[nodiscard]] auto start_time() const noexcept -> const xtd::date_time&;
205
208 [[nodiscard]] auto throw_on_failure() const noexcept -> bool;
211 auto throw_on_failure(bool value) noexcept -> settings&;
213
215
242 [[nodiscard]] static auto default_settings() noexcept -> xtd::tunit::settings&;
244
245 private:
246 friend class xtd::tunit::ostream_event_listener;
247 friend class xtd::tunit::ostream_unit_test;
248 friend class xtd::tunit::unit_test;
249
250 auto end_time(const xtd::date_time& end_time) noexcept -> settings&;
251 auto start_time(const xtd::date_time& start_time) noexcept -> settings&;
252
253 bool also_run_ignored_tests_ = false;
254 bool break_on_failure_ = false;
255 bool brief_ = false;
256 bool count_tests_ = false;
257 bool enable_stack_trace_ = false;
258 xtd::date_time end_time_;
259 xtd::int32 exit_status_ = 0;
260 xtd::string file_name_ = xtd::io::path::get_full_path(xtd::reflection::assembly::get_executing_assembly().location());
261 xtd::array<string> filter_tests_ = {"*.*"};
262 bool gtest_compatibility_ = false;
263 bool list_tests_ = false;
264 bool output_color_ = true;
265 bool output_json_ = false;
266 std::optional<xtd::string> output_json_path_;
267 bool output_xml_ = false;
268 std::optional<xtd::string> output_xml_path_;
269 xtd::uint32 random_seed_ = 0;
270 xtd::int32 repeat_tests_ = 1;
271 bool show_duration_ = true;
272 bool shuffle_tests_ = false;
273 xtd::date_time start_time_;
274 bool throw_on_failure_ = false;
275 };
276 }
277}
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
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
auto enable_stack_trace() const noexcept -> bool
Gets stack trace enabled.
auto repeat_test() const noexcept -> xtd::int32
Gets repeat tests count.
auto filter_tests() const noexcept -> const xtd::array< xtd::string > &
Gets filter tests.
auto show_duration() const noexcept -> bool
Gets if show duration for each test.
auto shuffle_test() const noexcept -> bool
Gets shuffle tests.
auto is_match_test_name(const xtd::string &test_class_name, const xtd::string &test_name) const noexcept -> bool
Return true if a specified test class name and specified test name match with the current filter test...
auto also_run_ignored_tests() const noexcept -> bool
Gets also run ignored test.
static auto default_settings() noexcept -> xtd::tunit::settings &
Gets default settings instance.
settings()=default
Creates new instance of settings.
auto start_time() const noexcept -> const xtd::date_time &
Gets unit test start time.
auto random_seed() const noexcept -> xtd::uint32
Gets random seed value.
auto list_tests() const noexcept -> bool
Gets list tests.
auto brief() const noexcept -> bool
Gets brief.
auto output_xml_path() const noexcept -> xtd::string
Gets output xml path.
auto break_on_failure() const noexcept -> bool
Gets break immediatly on failure.
auto output_json() const noexcept -> bool
Gets output xml.
auto count_tests() const noexcept -> bool
Gets count tests.
auto output_json_path() const noexcept -> xtd::string
Gets output json path.
auto repeat_tests(xtd::int32 value) noexcept -> settings &
Sets repeat tests count.
auto end_time() const noexcept -> const xtd::date_time &
Gets unit test end time.
auto output_xml() const noexcept -> bool
Gets output xml.
auto output_color() const noexcept -> bool
Gets output color.
auto throw_on_failure() const noexcept -> bool
Gets throw on failure.
auto gtest_compatibility() const noexcept -> bool
Gets google test comaptibility.
auto exit_status() const noexcept -> xtd::int32
Gets exit status.
The unit_test class is unit test base interface.
Definition unit_test.hpp:30
#define tunit_export_
Define shared library export.
Definition tunit_export.hpp:13
std::uint32_t uint32
Represents a 32-bit unsigned integer.
Definition uint32.hpp:23
std::int32_t int32
Represents a 32-bit signed integer.
Definition int32.hpp:25
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.