Skip to content

Commit 6d446b9

Browse files
authored
Add testhooks package documentation (#9373)
1 parent aff1163 commit 6d446b9

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

docs/development/testing.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,20 @@ You'll find a fully initialized task poller in any functional test suite, look f
122122

123123
_NOTE: The previous `testcore.TaskPoller` has been deprecated and should not be used in new code._
124124

125+
### testhooks package
126+
127+
The `testhooks` package injects test-specific behavior into production code paths that are otherwise
128+
difficult to test. This is a **last resort** - prefer mocking and dependency injection when possible.
129+
130+
**Example:**
131+
132+
The UpdateWithStart API has a race window between releasing a lock and starting a workflow where
133+
another request could create the same workflow first. The `UpdateWithStartInBetweenLockAndStart`
134+
hook lets tests inject a callback at this exact point, making it possible to reliably test
135+
conflict handling.
136+
137+
_NOTE: Tests using testhooks must be run with `-tags=test_dep`._
138+
125139
### softassert package
126140

127141
`softassert.That` is a "soft" assertion that logs an error if the given condition is false.

0 commit comments

Comments
 (0)