Skip to content

Commit cc89242

Browse files
authored
Merge pull request #328 from Inkrementator/readme_outdated
Update README to remove mention of stale feature TestCase and free funcs
2 parents 052b43f + 5bd8854 commit cc89242

1 file changed

Lines changed: 25 additions & 13 deletions

File tree

README.md

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -237,9 +237,27 @@ the "bar" tag.
237237

238238
The `@Setup` and `@Shutdown` UDAs can be attached to a
239239
free function in a module. If they are, they will be run before/after
240-
each `unittest` block in a composite (usually a module). This feature
241-
currently only works for `unittest` blocks, not free functions.
242-
Classes could override `setup` and `shutdown` already.
240+
each `unittest` block in a composite.
241+
A composite is usually a module, but you can use a dummy struct to only apply
242+
`@Setup` and `@Shutdown` functionality to a subset of tests:
243+
244+
```d
245+
struct Namespace {
246+
@Setup void setup() { writelnUt("Setup should run exactly twice"); }
247+
@("With setup1")
248+
unittest {
249+
}
250+
@("With setup2")
251+
unittest {
252+
}
253+
}
254+
@("No Setup")
255+
unittest {
256+
}
257+
258+
```
259+
Note: `@Setup` and `@Shutdown` only apply to the current scope. If you write
260+
more `unittest` inside structs, it won't apply to them.
243261

244262
Property-based testing
245263
----------------------
@@ -349,8 +367,8 @@ Command-line Parameters
349367
To run in single-threaded mode, use `-s`.
350368

351369
There is support for debug prints in the tests with the `-d` switch.
352-
TestCases and test functions can print debug output with the
353-
function `writelnUt` available [here](source/unit_threaded/io.d).
370+
Tests can print debug output with the function `writelnUt` available
371+
[here](source/unit_threaded/io.d).
354372

355373
Tests can be run in random order instead of in threads. To do so, use
356374
the `-r` option. A seed will be printed so that the same run can be
@@ -400,17 +418,11 @@ with the modules containing the tests as compile-time arguments (as
400418
strings).
401419

402420
There is no need to register tests. The registration is implicit
403-
and happens with:
404-
405-
* D's `unittest`` blocks
406-
* Functions with a camelCase name beginning with `test` (e.g. `testFoo()`)
407-
* Classes that derive from `TestCase` and override `test()`
421+
and happens for each `unittest` block.
408422

409423
The modules to be reflected on must be specified when calling
410424
`runTests` or `runTestsMain`, but that's usually done as shown in the dub configuration
411-
above. Private functions are skipped. `TestCase` also has support for
412-
`setup()` and `shutdown()`, child classes need only override the
413-
appropriate functions(s).
425+
above.
414426

415427
Tests can be hidden with the `@HiddenTest` attribute. This means
416428
that particular test doesn't get run by default but can still be run

0 commit comments

Comments
 (0)