Skip to content

SR-1417: Add non-optional overloads of XCTAssertEqual and XCTAssertNotEqual #2788

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

Merged
merged 2 commits into from
Jun 8, 2016

Conversation

briancroom
Copy link
Contributor

What's in this pull request?

This is #2551 updated to include a more comprehensive test that the failure message produced by the newly introduced overload is working as-desired.

From @nsalmoria's original pull request:

Previously, the only version of the functions that accepted values was the one that implicitly wraps them into Optionals. This generated a confusing error message when the assert failed. Having a separate overload that accepts non-optional types ensures that the correct description is printed when the assert fails.

Example:
XCTAssertEqual(1, 2, "message")

Previous error:
XCTAssertEqual failed: ("Optional(1)") is not equal to ("Optional(2)") - message

New error:
XCTAssertEqual failed: ("1") is not equal to ("2") - message

CC @modocache @mike-ferris-apple

Resolved bug number: (SR-1417)


Before merging this pull request to apple/swift repository:

  • Test pull request on Swift continuous integration.

Triggering Swift CI

The swift-ci is triggered by writing a comment on this PR addressed to the GitHub user @swift-ci. Different tests will run depending on the specific comment that you use. The currently available comments are:

Smoke Testing

Platform Comment
All supported platforms @swift-ci Please smoke test
All supported platforms @swift-ci Please smoke test and merge
OS X platform @swift-ci Please smoke test OS X platform
Linux platform @swift-ci Please smoke test Linux platform

Validation Testing

Platform Comment
All supported platforms @swift-ci Please test
All supported platforms @swift-ci Please test and merge
OS X platform @swift-ci Please test OS X platform
OS X platform @swift-ci Please benchmark
Linux platform @swift-ci Please test Linux platform

Lint Testing

Language Comment
Python @swift-ci Please Python lint

Note: Only members of the Apple organization can trigger swift-ci.

nsalmoria and others added 2 commits May 31, 2016 08:16
…tEqual

Previously, the only version of the functions that accepted values was the one that implicitly wraps them into Optionals. This generated a confusing error message when the assert failed. Having a separate overload that accepts non-optional types ensures that the correct description is printed when the assert fails.
@briancroom
Copy link
Contributor Author

@swift-ci please test

@@ -21,8 +21,24 @@ var XCTestTestSuite = TestSuite("XCTest")
// instantiate an NSInvocation with the given selector.


func execute(_ run: () -> ()) {
func execute(observers: [XCTestObservation] = [], _ run: () -> Void) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this function was originally added to get around the duplicate definitions of XCTest.run(). Seeing as how its role is expanding here, I wouldn't mind a rename at some point (in a future pull request maybe).

@modocache
Copy link
Contributor

Awesome! This is such a huge improvement over the current failure messages. Thanks, @nsalmoria and @briancroom!! 👍

I'll defer to @mike-ferris-apple to merge, in case this is something the Apple XCTest team cares about.

@mike-ferris
Copy link
Contributor

Sorry for the delay. This looks great to me. Not sure what happened with the ci... The link to the linux failure seems busted. I'll kick off another one.

@mike-ferris
Copy link
Contributor

@swift-ci please test

@mike-ferris
Copy link
Contributor

@modocache Please feel free to merge when this passes CI.

@modocache modocache merged commit fd136cc into swiftlang:master Jun 8, 2016
@modocache
Copy link
Contributor

Fantastic, thanks @mike-ferris-apple!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants