Skip to content

Commit b51114c

Browse files
authored
Create README.md
1 parent 0283aab commit b51114c

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

README.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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+
```

0 commit comments

Comments
 (0)