Commit cac0e08
committed
Use Constructor / Dispose instead of [Before(Test)] / [After(Test)]
Notes below are for TUnit version 0.25.21. As of version 1.0.78, Constructor / Dispose works the same as Before / After attributes.
Note that this fails the two test with the [NotInParallel] attribute, i.e. FilterPropertyThrowing and ExceptionFormatterThrowing.
The [Test Set Ups][1] and [Test Clean Ups][2] documentation mentions respectively:
> Most setup for a test can be performed in the constructor (think setting up mocks, assigning fields.)
and
> TUnit supports having your test class implement `IDisposable` or `IAsyncDisposable`. These will be called after your test has finished executing.
So I'm not sure what's the difference between Custructor/Dispose and [Before(Test)] / [After(Test)] attributes.
[1]: https://thomhurst.github.io/TUnit/docs/tutorial-extras/setup
[2]: https://thomhurst.github.io/TUnit/docs/tutorial-extras/cleanup1 parent 1608438 commit cac0e08
1 file changed
+6
-9
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
| 16 | + | |
17 | 17 | | |
18 | | - | |
19 | | - | |
| 18 | + | |
| 19 | + | |
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
43 | | - | |
44 | | - | |
| 43 | + | |
45 | 44 | | |
46 | 45 | | |
47 | 46 | | |
48 | 47 | | |
49 | 48 | | |
50 | | - | |
51 | | - | |
| 49 | + | |
52 | 50 | | |
53 | 51 | | |
54 | | - | |
55 | | - | |
| 52 | + | |
56 | 53 | | |
57 | 54 | | |
58 | 55 | | |
| |||
0 commit comments