xtd 1.0.0
Loading...
Searching...
No Matches
test_class.hpp
Go to the documentation of this file.
1
4#pragma once
5#include "../tunit_export.hpp"
6#define __XTD_TUNIT_INTERNAL__
8#undef __XTD_TUNIT_INTERNAL__
11#include "settings.hpp"
15#include <xtd/collections/generic/list>
16#include <xtd/date_time>
17#include <xtd/string>
18
20namespace xtd {
22 namespace tunit {
25 class test;
26 class unit_test;
28
40 public:
42
46
48
52 // The following variables are a hack to ensure that GoogleTestAdapter (Microsoft Visual Studio) will detect the tunit application as a google test application...
53 // See https://github.com/csoltenborn/GoogleTestAdapter/blob/master/GoogleTestAdapter/Core/GoogleTestConstants.cs
54 __unused_google_test_markers__();
55 }
56
57
59 virtual ~test_class() = default;
61
63
67 [[nodiscard]] auto elapsed_time() const noexcept -> xtd::time_span;
68
71 [[nodiscard]] auto name() const noexcept -> xtd::string;
72
75 [[nodiscard]] auto test_count() const noexcept -> xtd::usize;
76
79 [[nodiscard]] auto aborted_test_count() const noexcept -> xtd::usize;
80
83 [[nodiscard]] auto failed_test_count() const noexcept -> xtd::usize;
84
87 [[nodiscard]] auto ignored_test_count() const noexcept -> xtd::usize;
88
91 [[nodiscard]] auto succeed_test_count() const noexcept -> xtd::usize;
92
95 [[nodiscard]] auto start_time() const noexcept -> const xtd::date_time&;
96
99 [[nodiscard]] auto tests() const noexcept -> const test_collection&;
101
102 protected:
104
108 auto add_class_cleanup(const xtd::tunit::test& class_cleanup) noexcept -> void;
109
112 auto add_class_initialize(const xtd::tunit::test& class_initialize) noexcept -> void;
113
116 auto add_test_cleanup(const xtd::tunit::test& test_cleanup) noexcept -> void;
117
120 auto add_test_initialize(const xtd::tunit::test& test_initialize) noexcept -> void;
121
124 auto add_test_method(const xtd::tunit::test& test) noexcept -> void;
126
127 private:
128 friend class xtd::tunit::test;
129 friend class xtd::tunit::unit_test;
130 friend class xtd::tunit::class_initialize_attribute;
131 friend class xtd::tunit::class_cleanup_attribute;
132 friend class xtd::tunit::registered_test_class;
133 friend class xtd::tunit::test_initialize_attribute;
134 friend class xtd::tunit::test_cleanup_attribute;
135 friend class xtd::tunit::test_method_attribute;
136
137 [[nodiscard]] auto class_cleanup() const noexcept -> const xtd::tunit::test&;
138 [[nodiscard]] auto class_initialize() const noexcept -> const xtd::tunit::test&;
139 [[nodiscard]] auto test_cleanup() const noexcept -> const xtd::tunit::test&;
140 [[nodiscard]] auto test_initialize() const noexcept -> const xtd::tunit::test&;
141 [[nodiscard]] auto test_methods() const noexcept -> const test_collection&;
142
143 auto run(const xtd::tunit::unit_test& unit_test) -> void;
144
145 xtd::tunit::test class_cleanup_;
146 xtd::tunit::test class_initialize_;
147 xtd::date_time end_time_point;
148 xtd::string name_;
149 xtd::date_time start_time_;
150 xtd::tunit::test test_cleanup_;
151 xtd::tunit::test test_initialize_;
152 test_collection tests_;
153 };
154 }
155}
Contains xtd::tunit::class_cleanup_attribute class.
Contains xtd::tunit::class_initialize_attribute class.
Represents a strongly typed list of objects that can be accessed by index. Provides methods to search...
Definition list.hpp:80
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
Represents the registered test class.
Definition registered_test_class.hpp:20
Represents a test class.
Definition test_class.hpp:39
auto name() const noexcept -> xtd::string
Gets the name of the test class.
auto failed_test_count() const noexcept -> xtd::usize
Gets the failed test count.
auto add_test_initialize(const xtd::tunit::test &test_initialize) noexcept -> void
Adds the test initialize method.
auto ignored_test_count() const noexcept -> xtd::usize
Gets the ignored test count.
test_class()
Creates a new test_class instance.
Definition test_class.hpp:51
auto succeed_test_count() const noexcept -> xtd::usize
Gets the succeed test count.
auto add_class_initialize(const xtd::tunit::test &class_initialize) noexcept -> void
Adds the class initialize method.
auto elapsed_time() const noexcept -> xtd::time_span
Gets the elapsed time of the test class.
auto add_test_method(const xtd::tunit::test &test) noexcept -> void
Adds a test method.
auto add_test_cleanup(const xtd::tunit::test &test_cleanup) noexcept -> void
Adds the test cleanup method.
auto add_class_cleanup(const xtd::tunit::test &class_cleanup) noexcept -> void
Adds the class cleanup method.
auto start_time() const noexcept -> const xtd::date_time &
Gets the start time of the test class.
auto test_count() const noexcept -> xtd::usize
Gets the test count.
auto tests() const noexcept -> const test_collection &
Gets the tests array of this test class.
auto aborted_test_count() const noexcept -> xtd::usize
Gets the aborted test count.
xtd::collections::generic::list< xtd::tunit::test > test_collection
Represents a test collection.
Definition test_class.hpp:45
Represents a test method.
Definition test.hpp:29
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::size_t usize
Represents an unsigned size of any object in bytes.
Definition usize.hpp:22
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::test_cleanup_attribute class.
Contains xtd::tunit::test_initialize_attribute class.
Contains xtd::tunit::test_method_attribute class.
Contains tunit_export_ keyword.
Contains xtd::tunit::settings class.