Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged

Conversation

iamleeg
Copy link
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
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
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?

@iamleeg iamleeg requested a review from grynspan February 18, 2025 14:19
@iamleeg
Copy link
Contributor Author

iamleeg commented Feb 18, 2025

Fixes #863

@Column {
```swift
// Before
class RefrigeratorTests : XCTestCase
Copy link
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
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
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