Skip to content

Add an overview of test serialization to the XCTest migration guide#960

Merged
iamleeg merged 3 commits intomainfrom
iamleeg/122918733-serial-test-running-when-migrating-from-xctest
Feb 18, 2025
Merged

Add an overview of test serialization to the XCTest migration guide#960
iamleeg merged 3 commits intomainfrom
iamleeg/122918733-serial-test-running-when-migrating-from-xctest

Conversation

@iamleeg
Copy link
Copy Markdown
Contributor

@iamleeg iamleeg commented Feb 14, 2025

Describe test serialization in the article about migrating tests from XCTest.

Motivation:

Because XCTest runs tests in a suite serially by default, tests that people migrate from XCTest may encounter issues if they run in parallel.

Modifications:

Add an example of serializing a test suite to the migration guide, along with links to the docs about test parallelization.

Result:

The documentation on migrating tests from XCTest includes guidance on serializing tests within a suite.

Checklist:

  • Code and documentation should follow the style of the Style Guide.
  • If public symbols are renamed or modified, DocC references should be updated.

```swift
// Before
class RefrigeratorTests : XCTestCase
func testLightComesOn() async {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These functions are all marked async, but none of them uses await and all of them use try. Did you mean to mark them throws instead?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I just followed the existing examples in this article, for example the one in "Annotate known issues" that starts at line 574. Should we take a look at all of the examples in this article and decide what their signatures should be?

Comment thread Sources/Testing/Testing.docc/MigratingFromXCTest.md Outdated
Comment thread Sources/Testing/Testing.docc/MigratingFromXCTest.md Outdated
Comment thread Sources/Testing/Testing.docc/MigratingFromXCTest.md Outdated
Comment thread Sources/Testing/Testing.docc/MigratingFromXCTest.md Outdated
@iamleeg iamleeg requested a review from grynspan February 18, 2025 14:19
@iamleeg
Copy link
Copy Markdown
Contributor Author

iamleeg commented Feb 18, 2025

Fixes #863

@Column {
```swift
// Before
class RefrigeratorTests : XCTestCase
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
class RefrigeratorTests : XCTestCase
class RefrigeratorTests : XCTestCase {

@grynspan grynspan added documentation 📚 Improvements or additions to documentation enhancement New feature or request concurrency 🔀 Swift concurrency/sendability issues labels Feb 18, 2025
@grynspan grynspan added this to the Swift 6.x milestone Feb 18, 2025
@grynspan
Copy link
Copy Markdown
Contributor

Documentation changes only, can skip CI.

@iamleeg iamleeg merged commit 16f5846 into main Feb 18, 2025
@iamleeg iamleeg deleted the iamleeg/122918733-serial-test-running-when-migrating-from-xctest branch February 18, 2025 15:58
class RefrigeratorTests : XCTestCase {
func testLightComesOn() throws {
try FoodTruck.shared.refrigerator.openDoor()
XCTAssertEqual(FoodTruck.shared.refrigerator.lightState == .on)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
XCTAssertEqual(FoodTruck.shared.refrigerator.lightState == .on)
XCTAssertEqual(FoodTruck.shared.refrigerator.lightState, .on)

(Same comment in the XCTest below as well)

iamleeg added a commit that referenced this pull request Feb 19, 2025
…960)

Describe test serialization in the article about migrating tests from
XCTest.

### Motivation:

Because XCTest runs tests in a suite serially by default, tests that
people migrate from XCTest may encounter issues if they run in parallel.

### Modifications:

Add an example of serializing a test suite to the migration guide, along
with links to the docs about test parallelization.

### Result:

The documentation on migrating tests from XCTest includes guidance on
serializing tests within a suite.

### Checklist:

- [X] Code and documentation should follow the style of the [Style
Guide](https://github.com/apple/swift-testing/blob/main/Documentation/StyleGuide.md).
- [X] If public symbols are renamed or modified, DocC references should
be updated.
iamleeg added a commit that referenced this pull request Feb 19, 2025
…uide (#965)

- **Explanation**:
Updates the article on migrating tests from XCTest to tell developers
about test serialization.
  - **Scope**:
Documentation updates.
  - **Issues**:
#863 
  - **Original PRs**:
#960 #963 
  - **Risk**:
Purely documentation updates, no risk to the release.
  - **Testing**:
Build documentation and read Migrating a test from XCTest.
  - **Reviewers**:
@grynspan @stmontgomery
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

concurrency 🔀 Swift concurrency/sendability issues documentation 📚 Improvements or additions to documentation enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants