{"id":46323,"date":"2025-01-06T16:31:53","date_gmt":"2025-01-06T21:31:53","guid":{"rendered":"https:\/\/mjtsai.com\/blog\/?p=46323"},"modified":"2025-07-14T13:46:16","modified_gmt":"2025-07-14T17:46:16","slug":"swift-parameterized-testing","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2025\/01\/06\/swift-parameterized-testing\/","title":{"rendered":"Swift Parameterized Testing"},"content":{"rendered":"<p><a href=\"https:\/\/useyourloaf.com\/blog\/swift-parameterized-testing\/\">Keith Harrison<\/a>:<\/p>\n<blockquote cite=\"https:\/\/useyourloaf.com\/blog\/swift-parameterized-testing\/\">\n<p>Swift Testing calls the test function once for each value in the arguments collection. [&#8230;] If you pass a second argument, Swift Testing generates test cases for all combinations of the two arguments. [&#8230;] You&rsquo;re limited to at most two arguments. If you don&rsquo;t need every combination you can zip the arguments to pair them.<\/p>\n<\/blockquote>\n\n<p>Why use a parameterized test instead of just writing a <code>for<\/code> loop?<\/p>\n<blockquote cite=\"https:\/\/useyourloaf.com\/blog\/swift-parameterized-testing\/\">\n<p>Each call of the test function with a different argument is an independent test case than can run in parallel. It&rsquo;s much clearer when a test case fails. You can also rerun just the failing argument from the test navigator by clicking on the red failure icon[&#8230;]<\/p>\n<\/blockquote>\n\n<p>Previously:<\/p>\n<ul>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2024\/12\/17\/issues-adopting-swift-testing\/\">Issues Adopting Swift Testing<\/a><\/li>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2024\/07\/17\/swift-testing-in-xcode-16\/\">Swift Testing in Xcode 16<\/a><\/li>\n<\/ul>","protected":false},"excerpt":{"rendered":"<p>Keith Harrison: Swift Testing calls the test function once for each value in the arguments collection. [&#8230;] If you pass a second argument, Swift Testing generates test cases for all combinations of the two arguments. [&#8230;] You&rsquo;re limited to at most two arguments. If you don&rsquo;t need every combination you can zip the arguments to [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"apple_news_api_created_at":"2025-01-06T21:31:56Z","apple_news_api_id":"9fc6bfc1-0e21-492e-b721-3a89c6bc4ca9","apple_news_api_modified_at":"2025-01-06T21:31:56Z","apple_news_api_revision":"AAAAAAAAAAD\/\/\/\/\/\/\/\/\/\/w==","apple_news_api_share_url":"https:\/\/apple.news\/An8a_wQ4hSS63ITqJxrxMqQ","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,2586,30,2598,71,901,2796,268,226],"class_list":["post-46323","post","type-post","status-publish","format-standard","hentry","category-programming-category","tag-ios","tag-ios-18","tag-mac","tag-macos-15-sequoia","tag-programming","tag-swift-programming-language","tag-swift-testing","tag-testing","tag-xcode"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/46323","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=46323"}],"version-history":[{"count":1,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/46323\/revisions"}],"predecessor-version":[{"id":46324,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/46323\/revisions\/46324"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=46323"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=46323"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=46323"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}