Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use swift-custom-dump for all comparisons in RenderTesterResult #318

Merged
merged 1 commit into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 23 additions & 5 deletions WorkflowTesting/Sources/RenderTesterResult.swift
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,13 @@
line: UInt = #line
) -> RenderTesterResult<WorkflowType> where ActionType.WorkflowType == WorkflowType, ActionType: Equatable {
verifyAction(file: file, line: line) { appliedAction in
XCTAssertEqual(appliedAction, action, file: file, line: line)
XCTAssertNoDifference(

Check warning on line 83 in WorkflowTesting/Sources/RenderTesterResult.swift

View workflow job for this annotation

GitHub Actions / tutorial

'XCTAssertNoDifference(_:_:_:file:line:)' is deprecated: renamed to 'expectNoDifference'
appliedAction,
action,
"Action (First) does not match the expected action (Second)",
file: file,
line: line
)
}
}

Expand Down Expand Up @@ -120,7 +126,13 @@
file: StaticString = #file,
line: UInt = #line
) -> RenderTesterResult<WorkflowType> {
XCTAssertEqual(state, expectedState, file: file, line: line)
XCTAssertNoDifference(

Check warning on line 129 in WorkflowTesting/Sources/RenderTesterResult.swift

View workflow job for this annotation

GitHub Actions / development-tests (UnitTests)

'XCTAssertNoDifference(_:_:_:file:line:)' is deprecated: renamed to 'expectNoDifference'

Check warning on line 129 in WorkflowTesting/Sources/RenderTesterResult.swift

View workflow job for this annotation

GitHub Actions / tutorial

'XCTAssertNoDifference(_:_:_:file:line:)' is deprecated: renamed to 'expectNoDifference'
state,
expectedState,
"State (First) does not match the expected state (Second)",
file: file,
line: line
)
return self
}

Expand All @@ -136,10 +148,10 @@
) rethrows -> RenderTesterResult<WorkflowType> {
var initialState = initialState
try modifications(&initialState)
XCTAssertNoDifference(

Check warning on line 151 in WorkflowTesting/Sources/RenderTesterResult.swift

View workflow job for this annotation

GitHub Actions / development-tests (UnitTests)

'XCTAssertNoDifference(_:_:_:file:line:)' is deprecated: renamed to 'expectNoDifference'

Check warning on line 151 in WorkflowTesting/Sources/RenderTesterResult.swift

View workflow job for this annotation

GitHub Actions / tutorial

'XCTAssertNoDifference(_:_:_:file:line:)' is deprecated: renamed to 'expectNoDifference'
initialState,
state,
"Expected state does not match",
initialState,
"State (First) does not match the expected state (Second)",
file: file,
line: line
)
Expand All @@ -156,7 +168,13 @@
line: UInt = #line
) -> RenderTesterResult<WorkflowType> {
verifyOutput(file: file, line: line) { output in
XCTAssertEqual(output, expectedOutput, file: file, line: line)
XCTAssertNoDifference(

Check warning on line 171 in WorkflowTesting/Sources/RenderTesterResult.swift

View workflow job for this annotation

GitHub Actions / development-tests (UnitTests)

'XCTAssertNoDifference(_:_:_:file:line:)' is deprecated: renamed to 'expectNoDifference'

Check warning on line 171 in WorkflowTesting/Sources/RenderTesterResult.swift

View workflow job for this annotation

GitHub Actions / tutorial

'XCTAssertNoDifference(_:_:_:file:line:)' is deprecated: renamed to 'expectNoDifference'
output,
expectedOutput,
"Output (First) does not match the expected output (Second)",
file: file,
line: line
)
}
}
}
53 changes: 49 additions & 4 deletions WorkflowTesting/Tests/WorkflowRenderTesterFailureTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,14 @@ final class WorkflowRenderTesterFailureTests: XCTestCase {
rendering.doNoopAction(10)
}

expectingFailure(#"("noop(10)") is not equal to ("noop(70)")"#) {
expectingFailure("""
failed - XCTAssertNoDifference failed: …

− TestAction.noop(10)
+ TestAction.noop(70)

(First: −, Second: +) - Action (First) does not match the expected action (Second)
""") {
result.assert(action: TestAction.noop(70))
}

Expand Down Expand Up @@ -272,7 +279,14 @@ final class WorkflowRenderTesterFailureTests: XCTestCase {
}
}

expectingFailure(#"("sendOutput("second")") is not equal to ("noop(0)")"#) {
expectingFailure("""
failed - XCTAssertNoDifference failed: …

− TestAction.sendOutput("second")
+ TestAction.noop(0)

(First: −, Second: +) - Action (First) does not match the expected action (Second)
""") {
result.assert(action: TestAction.noop(0))
}

Expand All @@ -296,7 +310,14 @@ final class WorkflowRenderTesterFailureTests: XCTestCase {
rendering.doOutput("hello")
}

expectingFailure(#"("string("hello")") is not equal to ("string("nope")")"#) {
expectingFailure("""
failed - XCTAssertNoDifference failed: …

− TestWorkflow.Output.string("hello")
+ TestWorkflow.Output.string("nope")

(First: −, Second: +) - Output (First) does not match the expected output (Second)
""") {
result.assert(output: .string("nope"))
}

Expand Down Expand Up @@ -341,12 +362,36 @@ final class WorkflowRenderTesterFailureTests: XCTestCase {
}
}

func test_assertState() {
let result = TestWorkflow()
.renderTester(initialState: .idle)
.render { _ in }

expectingFailure("""
failed - XCTAssertNoDifference failed: …

− TestWorkflow.State.idle
+ TestWorkflow.State.sideEffect(key: "nah")

(First: −, Second: +) - State (First) does not match the expected state (Second)
""") {
result.assert(state: TestWorkflow.State.sideEffect(key: "nah"))
}
}

func test_assertStateModifications() {
let result = TestWorkflow()
.renderTester(initialState: .idle)
.render { _ in }

expectingFailure("Expected state does not match") {
expectingFailure("""
XCTAssertNoDifference failed: …

− TestWorkflow.State.idle
+ TestWorkflow.State.sideEffect(key: "nah")

(First: −, Second: +) - State (First) does not match the expected state (Second)
""") {
result.assertStateModifications { state in
state = .sideEffect(key: "nah")
}
Expand Down
Loading