{"action":"created","issue":{"url":"https://api.github.com/repos/watson-developer-cloud/ios-sdk/issues/157","repository_url":"https://api.github.com/repos/watson-developer-cloud/ios-sdk","labels_url":"https://api.github.com/repos/watson-developer-cloud/ios-sdk/issues/157/labels{/name}","comments_url":"https://api.github.com/repos/watson-developer-cloud/ios-sdk/issues/157/comments","events_url":"https://api.github.com/repos/watson-developer-cloud/ios-sdk/issues/157/events","html_url":"https://github.com/watson-developer-cloud/ios-sdk/issues/157","id":125270899,"number":157,"title":"Set `continueAfterFailure` to false for all tests","user":{"login":"glennrfisher","id":1957636,"avatar_url":"https://avatars.githubusercontent.com/u/1957636?v=3","gravatar_id":"","url":"https://api.github.com/users/glennrfisher","html_url":"https://github.com/glennrfisher","followers_url":"https://api.github.com/users/glennrfisher/followers","following_url":"https://api.github.com/users/glennrfisher/following{/other_user}","gists_url":"https://api.github.com/users/glennrfisher/gists{/gist_id}","starred_url":"https://api.github.com/users/glennrfisher/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/glennrfisher/subscriptions","organizations_url":"https://api.github.com/users/glennrfisher/orgs","repos_url":"https://api.github.com/users/glennrfisher/repos","events_url":"https://api.github.com/users/glennrfisher/events{/privacy}","received_events_url":"https://api.github.com/users/glennrfisher/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/watson-developer-cloud/ios-sdk/labels/general-sdk","name":"general-sdk","color":"fad8c7"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/watson-developer-cloud/ios-sdk/milestones/11","html_url":"https://github.com/watson-developer-cloud/ios-sdk/milestones/Release%200.4.0:%20Code%20Quality","labels_url":"https://api.github.com/repos/watson-developer-cloud/ios-sdk/milestones/11/labels","id":1537929,"number":11,"title":"Release 0.4.0: Code Quality","description":"Improve code quality, test quality, and devops procedures.","creator":{"login":"glennrfisher","id":1957636,"avatar_url":"https://avatars.githubusercontent.com/u/1957636?v=3","gravatar_id":"","url":"https://api.github.com/users/glennrfisher","html_url":"https://github.com/glennrfisher","followers_url":"https://api.github.com/users/glennrfisher/followers","following_url":"https://api.github.com/users/glennrfisher/following{/other_user}","gists_url":"https://api.github.com/users/glennrfisher/gists{/gist_id}","starred_url":"https://api.github.com/users/glennrfisher/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/glennrfisher/subscriptions","organizations_url":"https://api.github.com/users/glennrfisher/orgs","repos_url":"https://api.github.com/users/glennrfisher/repos","events_url":"https://api.github.com/users/glennrfisher/events{/privacy}","received_events_url":"https://api.github.com/users/glennrfisher/received_events","type":"User","site_admin":false},"open_issues":20,"closed_issues":0,"state":"open","created_at":"2016-01-23T05:06:12Z","updated_at":"2016-03-10T22:04:32Z","due_on":"2016-03-18T05:00:00Z","closed_at":null},"comments":2,"created_at":"2016-01-06T21:47:52Z","updated_at":"2016-03-11T18:32:51Z","closed_at":null,"body":"When writing the tests, we assumed that `XCTAssertNotNil(_:)` and `XCTAssertNil(_:)` statements would cause tests to fail. Instead, the test continues execution, which can cause later force unwrapped variables to crash the test instead of failing gracefully.\r\n\r\nWe should take another look at how we write our tests. Perhaps instead of something like:\r\n\r\n```swift\r\nservice.createModel(\"en-es\", name: \"custom-english-to-spanish\", fileKey: \"forced_glossary\", fileURL: fileURL!) { model, error in\r\n            \r\n    XCTAssertNotNil(model, \"Expected non-nil model to be returned.\")\r\n    Log.sharedLogger.error(\"\\(error)\")\r\n    creationExpectation.fulfill()\r\n    \r\n    // Add a small delay so the model is ready for delete.  This is not a normal flow of create and delete immediately\r\n    // so this is only a testing issue\r\n    sleep(3)\r\n    \r\n    self.service.deleteModel(model!) { error in\r\n        XCTAssertNil(error)\r\n        deletionExpectation.fulfill()\r\n    }\r\n}\r\n```\r\n\r\nwe should follow good practices and style with something like this instead:\r\n\r\n```swift\r\nservice.createModel(\"en-es\", name: \"custom-english-to-spanish\", fileKey: \"forced_glossary\", fileURL: fileURL!) { model, error in\r\n\r\n    guard let model = model else {\r\n        XCTFail(\"Expected non-nil model. Please upgrade your Language \" +\r\n            \"Translation Service to the \\\"Trainable\\\" plan.\")\r\n        creationExpectation.fulfill()\r\n        deletionExpectation.fulfill()\r\n        return\r\n    }\r\n\r\n    guard error == nil else {\r\n        XCTFail(\"Expected nil error.\")\r\n        Log.sharedLogger.error(\"\\(error)\")\r\n        creationExpectation.fulfill()\r\n        deletionExpectation.fulfill()\r\n        return\r\n    }\r\n    \r\n    creationExpectation.fulfill()\r\n    \r\n    // Add a small delay so the model is ready for delete.  This is not a normal flow of create and delete immediately\r\n    // so this is only a testing issue\r\n    sleep(3)\r\n    \r\n    self.service.deleteModel(model) { error in\r\n        XCTAssertNil(error)\r\n        deletionExpectation.fulfill()\r\n    }\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/watson-developer-cloud/ios-sdk/issues/comments/195490579","html_url":"https://github.com/watson-developer-cloud/ios-sdk/issues/157#issuecomment-195490579","issue_url":"https://api.github.com/repos/watson-developer-cloud/ios-sdk/issues/157","id":195490579,"user":{"login":"glennrfisher","id":1957636,"avatar_url":"https://avatars.githubusercontent.com/u/1957636?v=3","gravatar_id":"","url":"https://api.github.com/users/glennrfisher","html_url":"https://github.com/glennrfisher","followers_url":"https://api.github.com/users/glennrfisher/followers","following_url":"https://api.github.com/users/glennrfisher/following{/other_user}","gists_url":"https://api.github.com/users/glennrfisher/gists{/gist_id}","starred_url":"https://api.github.com/users/glennrfisher/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/glennrfisher/subscriptions","organizations_url":"https://api.github.com/users/glennrfisher/orgs","repos_url":"https://api.github.com/users/glennrfisher/repos","events_url":"https://api.github.com/users/glennrfisher/events{/privacy}","received_events_url":"https://api.github.com/users/glennrfisher/received_events","type":"User","site_admin":false},"created_at":"2016-03-11T18:32:51Z","updated_at":"2016-03-11T18:32:51Z","body":"One more gotcha: according to [this bug report](http://www.openradar.me/18110715) the `XCTAssert` and `XCTAssertNotNil` functions do not work with Swift structs.\r\n\r\nSo we will probably want to use an alternative check:\r\n\r\n`XCTAssert(results != nil)`\r\n`XCTAssert(error == nil)`\r\n\r\nor\r\n\r\n`guard let results = results else { XCTFail() }`\r\n`guard error != nil else { XCTFail() }`"}}