@@ -25,46 +25,43 @@ To complete
25
25
26
26
### 4. Guidelines for crate test utilities
27
27
28
- date: 2025-07-25
29
- status: Accepted
28
+ ** Date: ** 2025-07-25
29
+ ** Status: ** Accepted
30
30
31
31
### Context
32
32
33
- - For testing, crates may need to define reusable test utilities
34
- - Some of those utilities may need to be exposed to child crates to enable or facilitate writing tests
35
- - We want to isolate test utilities from production code as much as possible
36
- - We want to limit the number of feature flags so the Rust compiler may reuse built artifacts effectively, reducing build time
33
+ - Testing requires reusable utilities that may need to be shared across crates
34
+ - Test utilities should be isolated from production code while remaining accessible to child crates
35
+ - We need to minimize feature flags to optimize Rust compiler artifact reuse and reduce build times
37
36
38
37
### Decision
39
38
40
- Test utilities should be organized following these rules:
39
+ Test utilities must follow this organizational structure:
40
+
41
+ ** Core Rules:**
41
42
42
- 1 . Each crate must define its private and public test utilities in a ` test ` module
43
- 2 . A test utility should be made public if it is reused in a child crate or in the crate's integration tests
44
- 3 . Making a test utility public should not add any dependency to the crate
45
- 4 . Private test utilities should be behind ` cfg(test) `
46
- 5 . Importing a public test utility should always require an import path that contains a ` test ` module, so their misuse
47
- in production code can be easily identified
48
- 6 . No feature flag should be added to isolate test utilities from production code
43
+ 1 . All test utilities belong in a dedicated ` test ` module within each crate
44
+ 2 . Utilities become public only when used by child crates or integration tests
45
+ 3 . Public test utilities must not introduce additional dependencies
46
+ 4 . Private test utilities are gated behind ` cfg(test) `
47
+ 5 . Import paths must explicitly include ` test ` modules to prevent accidental production usage
48
+ 6 . Feature flags are prohibited for test utility isolation
49
49
50
- Specific cases:
50
+ ** Module Organization: **
51
51
52
- - Test doubles (fakes, dummies, mocks, stubs, etc.): should be located in a ` test::double ` module
53
- - Builders of test data should be located in a ` test::builder ` module
54
- - Extending a type with a test-only method should be done using extension traits located in the ` test ` module, which
55
- forces the import of a ` test ` -scoped symbol
56
- - Their name should be suffixed with ` TestExtension `
57
- - Implementation of those traits should preferably be below the trait definition, but if some methods need to access
58
- private properties, then the implementation may be located below their extended type
52
+ - ** Test doubles** (mocks, fakes, stubs): ` test::double ` module
53
+ - ** Test data builders** : ` test::builder ` module
54
+ - ** Test-only type extensions** : Extension traits in ` test ` module
55
+ - Trait names end with ` TestExtension `
56
+ - Implementations follow trait definitions, except when accessing private fields
59
57
60
58
#### Consequences
61
59
62
- - Enhanced consistency in code organization
63
- - Improved discoverability of test utilities
64
- - Clearer distinction between production and test code
65
- - Simplified maintenance of test utilities
66
- - Child crates can reuse common test utilities when needed
67
- - Feature flag usage is minimized, avoiding unnecessary recompilation
60
+ - Consistent codebase organization across all crates
61
+ - Clear separation between production and test code
62
+ - Improved discoverability and maintainability of test utilities
63
+ - Reduced build times through minimal feature flag usage
64
+ - Enhanced reusability of test utilities across child crates
68
65
69
66
---
70
67
@@ -96,7 +93,7 @@ The following guidelines will be adopted for implementing the `Dummy` trait:
96
93
97
94
---
98
95
99
- ## 2. Remove Artifacts serialization support when compiling to WebAssembly
96
+ ## 2. Remove artifacts serialization support when compiling to WebAssembly
100
97
101
98
date: 2025-02-26
102
99
status: Accepted
@@ -133,7 +130,7 @@ In the future, if we need to serialize and deserialize Artifacts in WebAssembly,
133
130
134
131
---
135
132
136
- ## 1. Record Architecture Decisions
133
+ ## 1. Record architecture decisions
137
134
138
135
date: 2025-02-26
139
136
status: Accepted
0 commit comments