{"id":17485,"date":"2017-03-22T15:57:20","date_gmt":"2017-03-22T19:57:20","guid":{"rendered":"http:\/\/mjtsai.com\/blog\/?p=17485"},"modified":"2017-03-22T15:57:20","modified_gmt":"2017-03-22T19:57:20","slug":"xctest-closure-based-expectations","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2017\/03\/22\/xctest-closure-based-expectations\/","title":{"rendered":"XCTest Closure Based Expectations"},"content":{"rendered":"<p><a href=\"http:\/\/www.mokacoding.com\/blog\/xctest-closure-based-expectation\/\">Giovanni Lodi<\/a>:<\/p>\n<blockquote cite=\"http:\/\/www.mokacoding.com\/blog\/xctest-closure-based-expectation\/\"><p>XCTest provides a method to generate an expectation that will fulfil based on the result of an <a href=\"https:\/\/developer.apple.com\/reference\/foundation\/nspredicate\"><code>NSPredicate<\/code><\/a>, <a href=\"https:\/\/developer.apple.com\/reference\/xctest\/xctestcase\/1500569-expectation\"><code>expectation(for:, evaluatedWith:, handler:)<\/code><\/a>.<\/p><p>Add to that the fact that <code>NSPredicate<\/code> can be <a href=\"https:\/\/developer.apple.com\/reference\/foundation\/nspredicate\/1416182-init\">initialized with a closure to evaluate<\/a>, and now you have a recipe for a closure based expectation.<\/p><\/blockquote>","protected":false},"excerpt":{"rendered":"<p>Giovanni Lodi: XCTest provides a method to generate an expectation that will fulfil based on the result of an NSPredicate, expectation(for:, evaluatedWith:, handler:).Add to that the fact that NSPredicate can be initialized with a closure to evaluate, and now you have a recipe for a closure based expectation.<\/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,1380,30,1381,71,901,268],"class_list":["post-17485","post","type-post","status-publish","format-standard","hentry","category-programming-category","tag-ios","tag-ios-10","tag-mac","tag-macos-10-12","tag-programming","tag-swift-programming-language","tag-testing"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/17485","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=17485"}],"version-history":[{"count":1,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/17485\/revisions"}],"predecessor-version":[{"id":17486,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/17485\/revisions\/17486"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=17485"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=17485"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=17485"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}