{"id":13966,"date":"2016-03-24T12:06:59","date_gmt":"2016-03-24T16:06:59","guid":{"rendered":"http:\/\/mjtsai.com\/blog\/?p=13966"},"modified":"2016-03-24T12:06:59","modified_gmt":"2016-03-24T16:06:59","slug":"xctestexpectation-gotchas","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2016\/03\/24\/xctestexpectation-gotchas\/","title":{"rendered":"XCTestExpectation Gotchas"},"content":{"rendered":"<p><a href=\"https:\/\/jeremywsherman.com\/blog\/2016\/03\/19\/xctestexpectation-gotchas\/\">Jeremy W. Sherman<\/a>:<\/p>\n<blockquote cite=\"https:\/\/jeremywsherman.com\/blog\/2016\/03\/19\/xctestexpectation-gotchas\/\">\n<p><code>XCTestExpectation<\/code> simplifies testing callback-style code,\nbut some of its design choices make tests using it fragile\nunless they&rsquo;re mitigated:<\/p>\n<ul>\n<li>It explodes if everything works right but later than you expected.<\/li>\n<li>It explodes if everything works right more than once.<\/li>\n<\/ul>\n<p>This article presents two concrete mitigations:<\/p>\n<ul>\n<li>Use weak references to ensure the expectation dies before it can cause you\ntrouble.<\/li>\n<li>Use a different promise API to do your waiting.<\/li>\n<\/ul>\n<\/blockquote>","protected":false},"excerpt":{"rendered":"<p>Jeremy W. Sherman: XCTestExpectation simplifies testing callback-style code, but some of its design choices make tests using it fragile unless they&rsquo;re mitigated: It explodes if everything works right but later than you expected. It explodes if everything works right more than once. This article presents two concrete mitigations: Use weak references to ensure the expectation [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"apple_news_api_created_at":"","apple_news_api_id":"","apple_news_api_modified_at":"","apple_news_api_revision":"","apple_news_api_share_url":"","apple_news_coverimage":0,"apple_news_coverimage_caption":"","apple_news_is_hidden":false,"apple_news_is_paid":false,"apple_news_is_preview":false,"apple_news_is_sponsored":false,"apple_news_maturity_rating":"","apple_news_metadata":"\"\"","apple_news_pullquote":"","apple_news_pullquote_position":"","apple_news_slug":"","apple_news_sections":"\"\"","apple_news_suppress_video_url":false,"apple_news_use_image_component":false,"footnotes":""},"categories":[4],"tags":[31,30,71,901,268,226],"class_list":["post-13966","post","type-post","status-publish","format-standard","hentry","category-programming-category","tag-ios","tag-mac","tag-programming","tag-swift-programming-language","tag-testing","tag-xcode"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/13966","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/comments?post=13966"}],"version-history":[{"count":1,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/13966\/revisions"}],"predecessor-version":[{"id":13967,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/13966\/revisions\/13967"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=13966"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=13966"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=13966"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}