Cannot disable test failure behaviour #163
Replies: 3 comments 12 replies
-
Expanded example of why this isn't always helpful: We have an effect that performs some work and if an error is thrown, we catch it and send a different action back to the store. However it is still useful for reporting purposes to report this issue. A simplified example of what this might look like: return .run { send in
do {
try await client.somethingImporant()
await send(.somethingWorked)
} catch {
reportIssue(error)
await send(.somethingFailed)
}
} If I'm testing the failure flow, I might override the let store = TestStore(...)
store.dependencies.client.somethingImportant = { throw SomeError() }
// this action returns the effect above
await store.send(.task)
await store.receive(.somethingFailed) The above test fails due to the unhandled
I just want to disable the exhaustive asserting against reported issues, its just not important to this test. Edit to say: on Stephen's suggestion I tried using the issue matcher for XCTExpectFailure {
$0.compactDescription.hasPrefix("failed - Caught error:")
} This sort of works around the issue, but I don't like that I lose my green "test passed" tick and have to settle for lots of grey X status indicators across my test suite for tests that I consider to be a pass. |
Beta Was this translation helpful? Give feedback.
-
Leaving a comment, since I am facing the exact situation with my tests (with Swift Testing):
|
Beta Was this translation helpful? Give feedback.
-
We don't really consider this an issue with the library as it stands today because the point of the library is to report issues that are testable. If you are reporting issues that are not programmer error / things to be fixed, then it may be the case that We will discuss more today and come back with any feedback or questions. But, since this isn't an issue with the library I am going to convert it to a discussion. Please feel free to continue the conversation over there! |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
The library automatically causes tests to fail when
reportIssue
is called, which is not always desirable behaviour and there is no easy way to stop this from happening.I'm in the process of migrating our custom error handling code over to using swift-issue-reporting. Our app uses TCA. I already have a number of tests where I'm explicitly configuring a dependency to throw an error to test the error handling path - even if we have explicit error handling logic we might still use
reportIssue
to log that issue (to Sentry, using a custom reporter). There is no need for this to trigger a test failure.I expected that this behaviour was just a custom "test" reporter but it isn't, it is hardcoded into
reportIssue
. I cannot usewithExpectedIssue
because the async version does not support XCTest - I cannot change over to Swift testing just to work around this issue. I can useXCTExpectFailure()
directly but this is a very broad solution that could hide genuine test failures.I think this behaviour should be configurable, or refactored into a default issue reporter that can be overridden using the existing API for configuring reporters.
Beta Was this translation helpful? Give feedback.
All reactions