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
XCTAssertNotNil cannot handle optionals #188
Comments
Another option would be to add SwifterSwift's very first XCTest extension 😆
|
@flashspys Thanks for pointing this out. I think we could also set XCTest to stop testing after failing once. The downside to that is we don't know of any failed tests after this until the next run, but I think it could be a fair compromise. |
This will not solve the situation in that a single test is crashing ( != failing) because some force-unwrap fails. |
@flashspys let me make sure I understand correctly, are you saying this test won't fail: let nilValue: Int? = nil
XCTAssertNotNil(nilValue) |
@flashspys Ok, I think we're on the same page. override func setUp() {
continueAfterFailure = false
} If 😅 Actually, I see what you mean now. |
I think it is more an UI Bug than I thought because your idea is right. It will fix it and even in the second example it will stop executing after And now I understand your idea from your first answer. I'm happy to announce that we don't even need to make a compromise. You can stop a single test after fail without stop the other tests. |
@flashspys Yeah the method I showed above would work. What's happening is there is no test report being shown due to the crash. Feel free to open a Pull Request making these changes to the tests where we use |
- new rgbComponents extension in UIColor - new docs from old docs repo - imporved tests for UIColor - Fixed #188
Fixed in v3.1.0 |
In your tests you are checking at various locations optionals not to be nil by passing them to the
XCTAssertNotNil
function. Unfortunally the function is unable to process Swift optionals and will threat even nil-optionals as not-nil. For this reason #187 is crashing and not failing, because first the optional is checked and then force-unwrapped. Another option to check optionals to be nil should be considered, for example as mentioned in this blogpost.The text was updated successfully, but these errors were encountered: