xtd 0.2.0
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 test_class(const test_class&) = default;
60 test_class& operator =(const test_class&) = default;
61 virtual ~test_class() = default;
63
65
69 xtd::time_span elapsed_time() const noexcept;
70
73 xtd::string name() const noexcept;
74
77 size_t test_count() const noexcept;
78
81 size_t aborted_test_count() const noexcept;
82
85 size_t failed_test_count() const noexcept;
86
89 size_t ignored_test_count() const noexcept;
90
93 size_t succeed_test_count() const noexcept;
94
97 const xtd::date_time& start_time() const noexcept;
98
101 const test_collection& tests() const noexcept;
103
104 protected:
106
110 void add_class_cleanup(const xtd::tunit::test& class_cleanup) noexcept;
111
114 void add_class_initialize(const xtd::tunit::test& class_initialize) noexcept;
115
118 void add_test_cleanup(const xtd::tunit::test& test_cleanup) noexcept;
119
122 void add_test_initialize(const xtd::tunit::test& test_initialize) noexcept;
123
126 void add_test_method(const xtd::tunit::test& test) noexcept;
128
129 private:
130 friend class xtd::tunit::test;
131 friend class xtd::tunit::unit_test;
132 friend class xtd::tunit::class_initialize_attribute;
133 friend class xtd::tunit::class_cleanup_attribute;
134 friend class xtd::tunit::registered_test_class;
135 friend class xtd::tunit::test_initialize_attribute;
136 friend class xtd::tunit::test_cleanup_attribute;
137 friend class xtd::tunit::test_method_attribute;
138
139 const xtd::tunit::test& class_cleanup() const noexcept;
140 const xtd::tunit::test& class_initialize() const noexcept;
141 const xtd::tunit::test& test_cleanup() const noexcept;
142 const xtd::tunit::test& test_initialize() const noexcept;
143 const test_collection& test_methods() const noexcept;
144
145 void run(const xtd::tunit::unit_test& unit_test);
146
147 xtd::tunit::test class_cleanup_;
148 xtd::tunit::test class_initialize_;
149 xtd::date_time end_time_point;
150 xtd::string name_;
151 xtd::date_time start_time_;
152 xtd::tunit::test test_cleanup_;
153 xtd::tunit::test test_initialize_;
154 test_collection tests_;
155 };
156 }
157}
Contains google test markers definitions.
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:79
Represents an instant in time, typically expressed as a date and time of day.
Definition date_time.hpp:85
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
void add_test_method(const xtd::tunit::test &test) noexcept
Adds a test method.
size_t succeed_test_count() const noexcept
Gets the succeed test count.
test_class()
Creates a new test_class instance.
Definition test_class.hpp:51
size_t test_count() const noexcept
Gets the test count.
xtd::string name() const noexcept
Gets the name of the test class.
size_t aborted_test_count() const noexcept
Gets the aborted test count.
size_t ignored_test_count() const noexcept
Gets the ignored test count.
void add_test_cleanup(const xtd::tunit::test &test_cleanup) noexcept
Adds the test cleanup method.
size_t failed_test_count() const noexcept
Gets the failed test count.
xtd::time_span elapsed_time() const noexcept
Gets the elapsed time of the test class.
void add_class_cleanup(const xtd::tunit::test &class_cleanup) noexcept
Adds the class cleanup method.
void add_class_initialize(const xtd::tunit::test &class_initialize) noexcept
Adds the class initialize method.
const xtd::date_time & start_time() const noexcept
Gets the start time of the test class.
void add_test_initialize(const xtd::tunit::test &test_initialize) noexcept
Adds the test initialize method.
const test_collection & tests() const noexcept
Gets the tests array of this test class.
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:29
#define tunit_export_
Define shared library export.
Definition tunit_export.hpp:13
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.