Skip to content

Commit

Permalink
Move XCTest API availability information to the porting guide
Browse files Browse the repository at this point in the history
  • Loading branch information
kateinoigakukun committed Dec 9, 2024
1 parent 31b6ecf commit 5e55e67
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
17 changes: 17 additions & 0 deletions src/getting-started/porting.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,20 @@ and they had to be disabled. These types are therefore absent in SwiftWasm Found
Related functions and properties on other types are also absent or disabled. We would like to make
them available in the future as soon as possible, and [we invite you to
contribute](../contribution-guide/index.md) and help us in achieving this goal!


## XCTest

[The swift-corelibs-xctest project](https://github.com/swiftlang/swift-corelibs-xctest) is available
in WebAssembly platforms, and you can use it to write tests for your SwiftWasm projects.

The following XCTest features are unavailable in SwiftWasm:

| API | Status |
|----------------|--------|
| `XCTestExpectation` | ❌ Unavailable |
| `XCTNSPredicateExpectation` | ❌ Unavailable |
| `XCTNSNotificationExpectation` | ❌ Unavailable |
| `XCTWaiter` | ❌ Unavailable |
| `XCTest.perform` | ❌ Unavailable |
| `XCTest.run` | ❌ Unavailable |
9 changes: 0 additions & 9 deletions src/getting-started/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,6 @@ for this test to pass. Your test functions should all start with `test`, please
documentation](https://developer.apple.com/documentation/xctest/defining_test_cases_and_test_methods)
for more details.

## XCTest limitations in the SwiftWasm toolchain

As was mentioned in [our section about Swift Foundation](/foundation.md), multi-threading and
file system APIs are currently not available in SwiftWasm. This means that `XCTestExpectation`
and test hooks related to `Bundle` (such as `testBundleWillStart(_:)` and `testBundleDidFinish(_:)`)
are not available in test suites compiled with SwiftWasm. If you have an existing test suite you're
porting to WebAssembly, you should use `#if os(WASI)` directives to exclude places where you use
these APIs from compilation.

## Building and running the test suite with `SwiftPM`

You can build your test suite by running this command in your terminal:
Expand Down

0 comments on commit 5e55e67

Please sign in to comment.