-
Notifications
You must be signed in to change notification settings - Fork 95
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
Improve test expressivity #101
Improve test expressivity #101
Conversation
Using specific assert functions will generate easier to understand failure messages if the tests were to fail. For example, in the `XCTAssertNil` case, it will say "something was unexpectedly not nil" instead of only "test failed".
@@ -290,7 +290,7 @@ final class MockerTests: XCTestCase { | |||
let simpleURL = URL(string: "https://host.com/api/resource") | |||
let mock = Mock(url: composedURL, dataType: .json, statusCode: 200, data: [.get: MockedData.exampleJSON.data]) | |||
let urlRequest = URLRequest(url: simpleURL!) | |||
XCTAssertEqual(composedURL.absoluteString, simpleURL!.absoluteString) | |||
XCTAssertEqual(composedURL.absoluteString, simpleURL?.absoluteString) | |||
XCTAssert(mock == urlRequest) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one I didn't change; somehow it is comparing a Mock
to a URLRequest
... but XCTAssertEqual
didn't seem to be able to figure out the generics, so I left it as-is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a very welcome change! I couldn't agree more, using the right assertions for the job will help a lot 🙂
guard let data = data, let image: UIImage = UIImage(data: data) else { | ||
XCTFail("Invalid data") | ||
XCTFail("Invalid data \(String(describing: data))") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You might want to fix this @BasThomas
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work, a small change that makes working with the tests much better!
The SwiftLint configuration would otherwise complain with the following error: > 🚫 variable declared in 'guard' condition is not usable in its body
MockerTests.xctest: Coverage: 95.75
Mocker.framework: Coverage: 88.04
Generated by 🚫 Danger Swift against 985b218 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@BasThomas can you have a look at the trailing whitespace warnings?
😢 yes. I sweat I have the setting enabled in Xcode. Wonder if something is broken. |
Also weird as I do not seem to have changed them? 🤔 |
|
I don't understand... Bitrise is unhappy, but I can't find the attached run that would have failed :( |
Congratulations! 🎉 This was released as part of Release 2.5.4 🚀 Generated by GitBuddy |
1 similar comment
Congratulations! 🎉 This was released as part of Release 2.5.4 🚀 Generated by GitBuddy |
Using specific assert functions will generate easier to understand failure messages if the tests were to fail. For example, in the
XCTAssertNil
case, it will say "something was unexpectedly not nil" instead of only "test failed".