File tree Expand file tree Collapse file tree 1 file changed +42
-0
lines changed
Expand file tree Collapse file tree 1 file changed +42
-0
lines changed Original file line number Diff line number Diff line change 1+ # swift-fatal-test-value
2+
3+ This macro eliminates boilerplate needed to set initial values of Dependency Injected instances' methods in unit tests.
4+ By simply annotating a struct or class with ` @FatalTestValue ` , it auto-generates an initializer invoking ` fatalError() ` for the closure.
5+
6+ ## Quick start
7+
8+ To get started, import FatalTestValue: ` import FatalTestValue ` , annotate your struct or class with ` @FatalTestValue ` :
9+
10+ ``` swift
11+ import FatalTestValue
12+
13+ @FatalTestValue
14+ struct Example {
15+ var create: @Sendable (Int ) async throws -> Void
16+ var read: @Sendable (Int ) async throws -> String
17+ var update: @Sendable (Int , String ) async throws -> Void
18+ var delete: (Int ) -> Void
19+ }
20+ ```
21+
22+ This will automatically generate an extension with a ` testValue ` property.
23+
24+
25+ ``` swift
26+ extension Example {
27+ public static let testValue = Example (
28+ create : { _ in
29+ fatalError ()
30+ },
31+ read : { _ in
32+ fatalError ()
33+ },
34+ update : { _ , _ in
35+ fatalError ()
36+ },
37+ delete : { _ in
38+ fatalError ()
39+ }
40+ )
41+ }
42+ ```
You can’t perform that action at this time.
0 commit comments