Skip to content

Commit 0423bc6

Browse files
committed
add outside-in test section
1 parent 4a19427 commit 0423bc6

File tree

1 file changed

+21
-14
lines changed

1 file changed

+21
-14
lines changed

docs/pages/principles/testing.md

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@ parent: Principles
1010

1111
# Testing recommendations
1212

13+
## Outside-In Tests
14+
* live outside of source code, in the tests/ directory
15+
* Describe the various types of outsid-in tests (integration, fuzz, e2e, API)
16+
* Reference topical guides
17+
* Provide suggestions for testing categories
18+
19+
1320
## Unit Tests
1421

1522
### Advantages of unit testing:
@@ -221,24 +228,13 @@ troubleshoot problems.
221228
### Guidelines for Diagnostic Tests
222229

223230
- Consider using the stdlib `unittest.TestCase` and other stdlib tools instead
224-
of pytest.
225-
- Allows running unit tests for diagnostics in production environments,
226-
without installing additional packages.
231+
of pytest. To allow running unit tests for diagnostics in production environments,
232+
without installing additional packages.
227233

228234
- Test files should be named `test_{{file under test}}.py`, so that stdlib
229235
unittest can find them easily.
230236

231-
### Running Diagnostic Tests:
232-
233-
stdlib's unittest can be used in environments where pytest is not available:
234-
235-
- To use unittest to run tests from an installed package (outside of your source
236-
repository), use `python -m unittest discover -s {{module.name}}`
237-
- To use unittest to run tests in your source folder, from your package root,
238-
use
239-
`python -m unittest discover --start-folder {{source folder}} --top-level-directory .`
240-
241-
#### Mocking and Patching to Isolate the code under test:
237+
### Mocking and Patching to Isolate the code under test:
242238

243239
Test Isolation is less necessary in diagnostic tests than unit tests. We often
244240
want diagnostic tests to execute compiled code, or run a test on GPU hardware.
@@ -257,3 +253,14 @@ def test_myfunction(t, patchme: Mock):
257253
patchme.assert_called_with("input from myfunction")
258254
t.assertIs(ret, patchme.return_value)
259255
```
256+
257+
### Running Diagnostic Tests:
258+
259+
stdlib's unittest can be used in environments where pytest is not available:
260+
261+
- To use unittest to run tests from an installed package (outside of your source
262+
repository), use `python -m unittest discover -s {{module.name}}`
263+
- To use unittest to run tests in your source folder, from your package root,
264+
use
265+
`python -m unittest discover --start-folder {{source folder}} --top-level-directory .`
266+

0 commit comments

Comments
 (0)