Skip to content

Commit

Permalink
swift basics custom display name section tuned
Browse files Browse the repository at this point in the history
  • Loading branch information
mecid committed Oct 29, 2024
1 parent 4ace303 commit 3ea02d6
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions _posts/2024-10-22-introducing-swift-testing-basics.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ func add(_ a: Int, _ b: Int) -> Int {
}
```

As you can see in the example above, we use the *@Test* macro to annotate our *verifyAdd* function. You don't need to name your test functions with any prefix; you only need to annotate tests with the *@Test* macro.

You can annotate the functions with *@Test* macro throwing and async. Throwing tests will fail whenever an unhandled error appears. Async test cases allows us to await values and verify the outcomes using the Swift Concurrency feature. You can also use them side-by-side with XCTest classes in a single project.
As you can see in the example above, we use the *@Test* macro to annotate our *verifyAdd* function. You don't need to name your test functions with any prefix; you only need to annotate tests with the *@Test* macro. We can also customize the display name to show a different title in the Test navigator.

```swift
@Test("Verify addition function") func verifyAdd() {
Expand All @@ -35,7 +33,7 @@ You can annotate the functions with *@Test* macro throwing and async. Throwing t
}
```

We can also customize the display name to show a different title in the Test navigator.
You can annotate the functions with *@Test* macro throwing and async. Throwing tests will fail whenever an unhandled error appears. Async test cases allows us to await values and verify the outcomes using the Swift Concurrency feature. You can also use them side-by-side with XCTest classes in a single project.

The *expect* macro allows you to assert the values in your tests. It replaces the whole collection of the assert functions from the XCTest framework with a single one. You place the boolean expression inside the *expect* macro, which will pass whenever it is true and fail whenever it is false.

Expand Down

0 comments on commit 3ea02d6

Please sign in to comment.