Skip to content

Commit cf28ea2

Browse files
committed
assertStateModifications: swift-custom-dump
- Before: assertStateModifications was difficult to use because the diffs for failed assertions were difficult to read - After: Incorporate CustomDump into assertStateModifications to make the assertions easy to read
1 parent 2ce9f82 commit cf28ea2

File tree

4 files changed

+29
-5
lines changed

4 files changed

+29
-5
lines changed

Package.resolved

+9
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,15 @@
3636
"version" : "1.1.4"
3737
}
3838
},
39+
{
40+
"identity" : "swift-custom-dump",
41+
"kind" : "remoteSourceControl",
42+
"location" : "https://github.com/pointfreeco/swift-custom-dump",
43+
"state" : {
44+
"revision" : "82645ec760917961cfa08c9c0c7104a57a0fa4b1",
45+
"version" : "1.3.3"
46+
}
47+
},
3948
{
4049
"identity" : "swift-identified-collections",
4150
"kind" : "remoteSourceControl",

Package.swift

+5-1
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ let package = Package(
6464
.package(url: "https://github.com/pointfreeco/swift-identified-collections", from: "1.0.0"),
6565
.package(url: "https://github.com/pointfreeco/swift-macro-testing", from: "0.4.0"),
6666
.package(url: "https://github.com/pointfreeco/swift-perception", from: "1.1.4"),
67+
.package(url: "https://github.com/pointfreeco/swift-custom-dump", from: "1.3.3"),
6768
],
6869
targets: [
6970
// MARK: Workflow
@@ -80,7 +81,10 @@ let package = Package(
8081
),
8182
.target(
8283
name: "WorkflowTesting",
83-
dependencies: ["Workflow"],
84+
dependencies: [
85+
"Workflow",
86+
.product(name: "CustomDump", package: "swift-custom-dump"),
87+
],
8488
path: "WorkflowTesting/Sources",
8589
linkerSettings: [.linkedFramework("XCTest")]
8690
),

WorkflowTesting/Sources/RenderTesterResult.swift

+14-3
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17+
import CustomDump
1718
import Workflow
1819
import XCTest
1920

@@ -129,13 +130,23 @@ extension RenderTesterResult where WorkflowType.State: Equatable {
129130
/// and is expected to mutate it to match the new state.
130131
@discardableResult
131132
public func assertStateModifications(
132-
file: StaticString = #file,
133+
_ modifications: (inout WorkflowType.State) throws -> Void,
134+
fileID: StaticString = #fileID,
135+
filePath: StaticString = #filePath,
133136
line: UInt = #line,
134-
_ modifications: (inout WorkflowType.State) throws -> Void
137+
column: UInt = #column
135138
) rethrows -> RenderTesterResult<WorkflowType> {
136139
var initialState = initialState
137140
try modifications(&initialState)
138-
XCTAssertEqual(state, initialState, "Expected state does not match", file: file, line: line)
141+
expectNoDifference(
142+
initialState,
143+
state,
144+
"Expected state does not match",
145+
fileID: fileID,
146+
filePath: filePath,
147+
line: line,
148+
column: column
149+
)
139150
return self
140151
}
141152
}

WorkflowTesting/Tests/WorkflowRenderTesterFailureTests.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ final class WorkflowRenderTesterFailureTests: XCTestCase {
341341
}
342342
}
343343

344-
func test_assertState() {
344+
func test_assertStateModifications() {
345345
let result = TestWorkflow()
346346
.renderTester(initialState: .idle)
347347
.render { _ in }

0 commit comments

Comments
 (0)