xtd 0.2.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/date_time>
16#include <xtd/string>
17#include <vector>
18
20namespace xtd {
22 namespace tunit {
24 class registered_test_class;
25 class test;
26 class unit_test;
28
40 public:
42
46 // The following variables are a hack to ensure that GoogleTestAdapter (Microsoft Visual Studio) will detect the tunit application as a google test application...
47 // See https://github.com/csoltenborn/GoogleTestAdapter/blob/master/GoogleTestAdapter/Core/GoogleTestConstants.cs
48 __unused_google_test_markers__();
49 }
51
53 test_class(const test_class&) = default;
54 test_class& operator =(const test_class&) = default;
55 virtual ~test_class() = default;
57
59
63 xtd::time_span elapsed_time() const noexcept;
64
67 xtd::string name() const noexcept;
68
71 size_t test_count() const noexcept;
72
75 size_t aborted_test_count() const noexcept;
76
79 size_t failed_test_count() const noexcept;
80
83 size_t ignored_test_count() const noexcept;
84
87 size_t succeed_test_count() const noexcept;
88
91 const xtd::date_time& start_time() const noexcept;
92
95 const std::vector<xtd::tunit::test>& tests() const noexcept;
97
98 protected:
100
104 void add_class_cleanup(const xtd::tunit::test& class_cleanup) noexcept;
105
108 void add_class_initialize(const xtd::tunit::test& class_initialize) noexcept;
109
112 void add_test_cleanup(const xtd::tunit::test& test_cleanup) noexcept;
113
116 void add_test_initialize(const xtd::tunit::test& test_initialize) noexcept;
117
120 void add_test_method(const xtd::tunit::test& test) noexcept;
122
123 private:
124 friend class xtd::tunit::test;
125 friend class xtd::tunit::unit_test;
126 friend class xtd::tunit::class_initialize_attribute;
127 friend class xtd::tunit::class_cleanup_attribute;
128 friend class xtd::tunit::registered_test_class;
129 friend class xtd::tunit::test_initialize_attribute;
130 friend class xtd::tunit::test_cleanup_attribute;
131 friend class xtd::tunit::test_method_attribute;
132
133 const xtd::tunit::test& class_cleanup() const noexcept;
134 const xtd::tunit::test& class_initialize() const noexcept;
135 const xtd::tunit::test& test_cleanup() const noexcept;
136 const xtd::tunit::test& test_initialize() const noexcept;
137 const std::vector<xtd::tunit::test>& test_methods() const noexcept;
138
139 void run(const xtd::tunit::unit_test& unit_test);
140
141 xtd::tunit::test class_cleanup_;
142 xtd::tunit::test class_initialize_;
143 xtd::date_time end_time_point;
144 xtd::string name_;
145 xtd::date_time start_time_;
146 xtd::tunit::test test_cleanup_;
147 xtd::tunit::test test_initialize_;
148 std::vector<xtd::tunit::test> tests_;
149 };
150 }
151}
Contains google test markers definitions.
Contains xtd::tunit::class_cleanup_attribute class.
Contains xtd::tunit::class_initialize_attribute class.
Represents an instant in time, typically expressed as a date and time of day.
Definition date_time.hpp:85
This attribute is use to add cleanup class method to class test attribute.
Definition class_cleanup_attribute.hpp:21
This attribute is use to add initialize class method to class test attribute.
Definition class_initialize_attribute.hpp:21
Represents the registered test class.
Definition registered_test_class.hpp:20
Represents a test class.
Definition test_class.hpp:39
test_class()
Creates a new test_class instance.
Definition test_class.hpp:45
xtd::time_span elapsed_time() const noexcept
Gets the elapsed time of the test class.
Represents a test cleanup attribute.
Definition test_cleanup_attribute.hpp:21
Represents a test initialize attribute.
Definition test_initialize_attribute.hpp:17
Represents a test method attribute.
Definition test_method_attribute.hpp:23
Represents a test method.
Definition test.hpp:29
The unit_test class is unit test base interface.
Definition unit_test.hpp:28
#define tunit_export_
Define shared library export.
Definition tunit_export.hpp:13
#define class_initialize_(method_name)
add initialize class method to class test.
Definition class_initialize_attribute.hpp:46
#define test_initialize_(method_name)
Helper to create a test initialize method in a test class.
Definition test_initialize_attribute.hpp:40
#define class_cleanup_(method_name)
Add class cleanup method to class test.
Definition class_cleanup_attribute.hpp:46
#define test_cleanup_(method_name)
Helper to create a test cleanup method in a test class.
Definition test_cleanup_attribute.hpp:44
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.hpp:10
Represents a time interval.
Definition time_span.hpp:29
Contains xtd::tunit::test_cleanup_attribute class.
Contains xtd::tunit::test_initialize_attribute class.
Contains xtd::tunit::test_method_attribute class.
Contains xtd::tunit::settings class.