Skip to content

Commit eef5f3d

Browse files
CraigMacomberanthony-murphy-agent
authored andcommitted
Tree schema open polymorphism examples (microsoft#25805)
## Description Add some examples showing patterns for open polymorphism with tree schema. These examples are derived from those in microsoft#23084, showing cases which motivate that work, but do not (yet) include the examples from that PR showing how it helps. Merging this PR first will help that one better show its value.
1 parent 5a8ff33 commit eef5f3d

File tree

2 files changed

+753
-0
lines changed

2 files changed

+753
-0
lines changed

packages/dds/tree/src/test/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,22 @@ Assuming all code has such tests, and only relies of documented behavior of the
2222
In practice, testing of this type will not cover all cases: this is expected.
2323
When a testing gap is found and determined worth covering (for example due to a bug, new code, or audit of coverage), it should always be possible to address it by adding more tests following this pattern (for example regression tests can always be implemented as a `spec` test for the code which contained the bug).
2424
Note that the fact that this approach is always possible does not make it the best approach: using spec tests in this way should be the first option considered, but if a better testing approach is found, it can be used instead as long as it is documented appropriately.
25+
- `integration`: Tests for using multiple APIs together.
26+
If there is a corresponding `spec` file which is sufficiently large in scope, the tests should be placed within it:
27+
only when the tests don't cleanly correspond to a particular source file should a separate `integration` file be created.
28+
When created, the file should be placed in the `src/test` directory's sub folder which is the most nested it can be while still including all the relevant APIs.
29+
For example tests and examples of using `src/thing/foo` with `src/thing/bar` would belong in `src/test/thing` and could be named something like `fooWithBar.integration.ts`.
30+
If it is not entirely clear exactly what tests belong in a given `integration` file based on just the file name, a doc comment should be included at the top explaining the scope.
2531

2632
Any other kinds of test files should be documented when created by adding them to this list.
2733

34+
## Examples
35+
36+
Code showing how to use an API can be included in tests.
37+
Such tests should mention that they are an "example" somewhere in the file name, suite or test name.
38+
These are not intended to serve as tests for the APIs, but are written as tests to ensure the examples stay up to date.
39+
If there is a corresponding `spec` file, the examples should be included within it: only when the examples don't cleanly correspond to a particular source file should a separate `examples` file be created. When created, the file should be places in the `src/test` directory's sub folder which corresponds to the most nested it can be while still including all the relevant APIs. For example an example of using `src/thing/foo` with `src/thing/bar` would belong in `src/test/thing` and could be named something like `fooWithBar.example.ts`.
40+
2841
## Test Tagging
2942

3043
Tests can be [tagged](https://mochajs.org/next/explainers/tagging/).

0 commit comments

Comments
 (0)