what's new in Unit test

Asked on 03/04/2025

1 search

In the context of unit testing, several new features and improvements were introduced at WWDC 2024, particularly focusing on Swift Testing and Xcode 16:

  1. Swift Testing:

    • Swift Testing is now the default testing solution in Xcode 16. It provides expressive APIs, making it simple to write tests. It is cross-platform and developed as an open-source package.
    • Tests are written by adding a function with a @test attribute to your test suite. You can use macros like #expect to evaluate the result of Swift expressions.
    • Swift Testing supports parameterized tests, allowing each provided argument to run in parallel as its own test case.
    • Tags can be used to organize and filter tests, making it easier to manage large test suites. Tags can be applied to individual tests or entire suites, and tests can be grouped by these tags in the test navigator.
  2. Xcode 16:

    • Xcode 16 introduces improvements to the test navigator, allowing for better organization and execution of tests. You can use quick actions to rerun specific tests quickly.
    • The test macro in Swift Testing allows for parameterized tests, where each argument runs as its own test case, and the navigator displays each case individually.
    • The test plan editor has been redesigned to help manage test plans more effectively, including the ability to save tag preferences.

For more detailed information, you can refer to the sessions Meet Swift Testing and Go further with Swift Testing.

what's new in Unit test | Ask WWDC