xtd 0.2.0
settings.h
Go to the documentation of this file.
1 #pragma once
5 #include "../tunit_export.h"
6 #include <xtd/io/path>
7 #include <xtd/date_time>
8 #include <xtd/environment>
9 #include <xtd/ustring>
10 #include <cstdint>
11 #include <cstdlib>
12 
14 namespace xtd {
16  namespace tunit {
23  class tunit_export_ settings final {
24  public:
26 
29  settings() = default;
31 
33  settings(const settings&) = default;
34  settings& operator =(const settings&) = default;
36 
38 
42  static xtd::tunit::settings& default_settings() noexcept;
43 
46  bool also_run_ignored_tests() const noexcept;
47 
50  void also_run_ignored_tests(bool also_run_ignored_tests) noexcept;
51 
54  bool break_on_failure() const noexcept;
55 
58  bool brief() const noexcept;
59 
62  void brief(bool brief) noexcept;
63 
66  void break_on_failure(bool break_on_failure) noexcept;
67 
70  bool throw_on_failure() const noexcept;
71 
74  void throw_on_failure(bool break_on_failure) noexcept;
75 
78  bool count_tests() const noexcept;
79 
82  void count_tests(bool count_tests) noexcept;
83 
88  int32 exit_status() const noexcept;
89 
94  void exit_status(int32 exit_status) noexcept;
95 
99  const std::vector<ustring>& filter_tests() const noexcept;
100 
104  void filter_tests(const std::vector<ustring>& filter_tests) noexcept;
105 
108  bool gtest_compatibility() const noexcept;
109 
112  void gtest_compatibility(bool gtest_compatibility) noexcept;
113 
116  bool is_match_test_name(const xtd::ustring& test_class_name, const xtd::ustring& test_name) const noexcept;
117 
120  bool list_tests() const noexcept;
121 
124  void list_tests(bool list_tests) noexcept;
125 
128  bool output_color() const noexcept;
129 
132  void output_color(bool output_color) noexcept;
133 
136  bool output_json() const noexcept;
137 
140  void output_json(bool output_json) noexcept;
141 
144  bool output_xml() const noexcept;
145 
148  void output_xml(bool output_xml) noexcept;
149 
152  xtd::ustring output_json_path() const noexcept;
153 
156  void output_json_path(const xtd::ustring& output_json_path) noexcept;
157 
160  xtd::ustring output_xml_path() const noexcept;
161 
164  void output_xml_path(const xtd::ustring& output_xml_path) noexcept;
165 
169  bool shuffle_test() const noexcept;
170 
174  void shuffle_test(bool shuffle_test) noexcept;
175 
179  uint32 random_seed() const noexcept;
180 
184  void random_seed(uint32 random_seed) noexcept;
185 
189  int32 repeat_test() const noexcept;
190 
194  void repeat_tests(int32 repeat_tests) noexcept;
195 
198  bool show_duration() const noexcept;
199 
202  void show_duration(bool show_duration) noexcept;
203 
206  const xtd::date_time& end_time() const noexcept;
207 
210  const xtd::date_time& start_time() const noexcept;
211 
215  bool enable_stack_trace() const noexcept;
216 
220  void enable_stack_trace(bool enable_stack_trace) noexcept;
222 
223  private:
224  friend class unit_test;
225  friend class ostream_event_listener;
226  friend class ostream_unit_test;
227 
228  bool pattern_compare(const xtd::ustring& name, const xtd::ustring& pattern) const noexcept;
229 
230  void end_time(const xtd::date_time& end_time) noexcept;
231  void start_time(const xtd::date_time& start_time) noexcept;
232 
233  bool also_run_ignored_tests_ = false;
234  bool break_on_failure_ = false;
235  bool brief_ = false;
236  bool throw_on_failure_ = false;
237  std::vector<ustring> filter_tests_;
238  int32 exit_status_ = EXIT_SUCCESS;
239  bool gtest_compatibility_ = false;
240  bool count_tests_ = false;
241  bool list_tests_ = false;
242  bool output_color_ = true;
243  bool output_json_ = false;
244  bool output_xml_ = false;
245  xtd::ustring output_json_path_ = "tests.json";
246  xtd::ustring output_xml_path_ = "tests.xml";
248  bool show_duration_ = true;
249  bool shuffle_tests_ = false;
250  uint32 random_seed_ = 0;
251  int32 repeat_tests_ = 1;
252  bool enable_stack_trace_ = false;
253  xtd::date_time start_time_;
254  xtd::date_time end_time_;
255  };
256  }
257 }
The ostream_unit_test class is ostream unit test interface.
Definition: ostream_unit_test.h:22
The xtd namespace contains all fundamental classes to access Hardware, Os, System, and more.
Definition: system_report.h:17
The ostream_unit_test class is a specialisation of event_listener class for writing events in std::os...
Definition: ostream_event_listener.h:23
Represents text as a sequence of UTF-8 code units.
Definition: ustring.h:46
exit_status
Specifies exit status for the xtd::environment::exit method.
Definition: exit_status.h:18
Represents an instant in time, typically expressed as a date and time of day.
Definition: date_time.h:78
int_least32_t int32
Represents a 32-bit signed integer.
Definition: types.h:129
uint_least32_t uint32
Represents a 32-bit unsigned integer.
Definition: types.h:239
static xtd::ustring get_full_path(const xtd::ustring &path)
Returns the absolute path for the specified path string.
The unit_test class is unit test base interface.
Definition: unit_test.h:35
The settings class contains xtd.tunit settings.
Definition: settings.h:23
static xtd::collections::specialized::string_vector get_command_line_args()
Returns a string array containing the command-line arguments for the current process.