You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/test-fixtures.md
+62-17Lines changed: 62 additions & 17 deletions
Original file line number
Diff line number
Diff line change
@@ -51,11 +51,18 @@ class UniqueTestsFixture {
51
51
}
52
52
```
53
53
54
-
The two test cases here will create uniquely-named derived classes of UniqueTestsFixture and thus can access the `getID()` protected method and `conn` member variables. This ensures that both the test cases are able to create a DBConnection using the same method (DRY principle) and that any ID's created are unique such that the order that tests are executed does not matter.
54
+
The two test cases here will create uniquely-named derived classes of
55
+
UniqueTestsFixture and thus can access the `getID()` protected method
56
+
and `conn` member variables. This ensures that both the test cases
57
+
are able to create a DBConnection using the same method
58
+
(DRY principle) and that any ID's created are unique such that the
59
+
order that tests are executed does not matter.
55
60
56
61
### 2. `METHOD_AS_TEST_CASE`
57
62
58
-
`METHOD_AS_TEST_CASE` lets you register a member function of a class as a Catch2 test case. The class will be separately instantiated for each method registered in this way.
63
+
`METHOD_AS_TEST_CASE` lets you register a member function of a class
64
+
as a Catch2 test case. The class will be separately instantiated
65
+
for each method registered in this way.
59
66
60
67
```cpp
61
68
class TestClass {
@@ -75,40 +82,78 @@ public:
75
82
METHOD_AS_TEST_CASE( TestClass::testCase, "Use class's method as a test case", "[class]" )
76
83
```
77
84
78
-
This type of fixture is similar to [TEST_CASE_METHOD](#1-test_case_method) except in this case it will directly use the provided class to create an object rather than a derived class.
85
+
This type of fixture is similar to [TEST_CASE_METHOD](#1-test_case_method) except in this
86
+
case it will directly use the provided class to create an object rather than a derived
87
+
class.
79
88
80
89
### 3. `TEST_CASE_PERSISTENT_FIXTURE`
81
90
82
-
> [Introduced](link-to-issue-or-PR) in Catch2 X.Y.Z
91
+
> [Introduced](https://github.com/catchorg/Catch2/pull/2885) in Catch2 X.Y.Z
83
92
84
93
`TEST_CASE_PERSISTENT_FIXTURE` behaves in the same way as
85
94
[TEST_CASE_METHOD](#1-test_case_method) except that there will only be
86
95
one instance created throughout the entire run of a test case. To
87
96
demonstrate this have a look at the following example:
0 commit comments