Commit 4d4fc36
authored
[TASK] Do not assertX but fail() in tearDown() (#660)
phpunit has a best practice that tests should usually
have at least one assertion to be sure they actually
do something. All assertions thus raise a counter that
is checked after test execution. If zero, phpunit marks
the test risky with "test has no assertion".
There are two ways to suppress this:
* Setting beStrictAboutTestsThatDoNotTestAnything="false"
via phpunit config
* Adding #[DoesNotPerformAssertions] attribute to single
tests to actively mark tests that do not assert something
as legit
Our abstract UnitTestCase spoils this by always doing
assertions in tearDown(). The patch turns these
assertions into check+fail() code instead. Unit tests that
don't have assertions for whatever reason are now properly
marked as risky as intended by phpunit.
Releases: main1 parent 32cc772 commit 4d4fc36
1 file changed
+18
-16
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
127 | 127 | | |
128 | 128 | | |
129 | 129 | | |
130 | | - | |
131 | | - | |
132 | | - | |
133 | | - | |
134 | | - | |
135 | | - | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
136 | 137 | | |
137 | 138 | | |
138 | 139 | | |
| |||
175 | 176 | | |
176 | 177 | | |
177 | 178 | | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
178 | 184 | | |
179 | | - | |
180 | | - | |
181 | | - | |
182 | | - | |
183 | | - | |
184 | | - | |
185 | | - | |
186 | 185 | | |
187 | | - | |
188 | | - | |
189 | | - | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
190 | 192 | | |
191 | 193 | | |
192 | 194 | | |
| |||
0 commit comments