Skip to content

Update MigratingFromXCTest making it clear you must import Testing. #158

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

Merged
merged 2 commits into from
Jan 3, 2024
Merged

Update MigratingFromXCTest making it clear you must import Testing. #158

merged 2 commits into from
Jan 3, 2024

Conversation

Sajjon
Copy link
Contributor

@Sajjon Sajjon commented Dec 12, 2023

Update MigratingFromXCTest to make it clear one must import Testing

Motivation:

Other guides mention that one has to import Testing, e.g. DefiningTests, but readers will see MigratingFromXCTest before they see DefiningTests, and "following along" while reading makes code not compile (since must import Testing).

Modifications:

Made it clear that with XCTest one needs import XCTest and now with swift-testing one needs to import Testing.

Result:

A more clear guide, that is easier to follow along.

Checklist:

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

Copy link
Contributor

@grynspan grynspan left a comment

Choose a reason for hiding this comment

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

Thanks for taking a look at this! We should strive to avoid redundant content in the code snippets that may make it harder to see the difference between the two libraries. The code snippets aren't meant to represent complete Swift files, but simply examples of how various features are used.

Rather than including the import statements in each snippet, how about adding a short section after "Adding the testing library as a dependency" but before "Converting test classes" that explains the change in imported libraries?

I would also take the time to mention in that section that a single test file can contain tests written with either library (i.e. it is okay to continue importing XCTest if not all tests in a file are ready to be converted to swift-testing.) If you can think of other relevant information, feel free to add it too.

@Sajjon
Copy link
Contributor Author

Sajjon commented Dec 13, 2023

@grynspan Perhaps like this?

@Sajjon Sajjon requested a review from grynspan December 13, 2023 20:17
@Sajjon Sajjon requested a review from grynspan December 13, 2023 20:50
@Sajjon Sajjon requested a review from grynspan December 14, 2023 08:20
@grynspan
Copy link
Contributor

@swift-ci please test

}
}

A single source file can contain tests written with XCTest as well as other

Choose a reason for hiding this comment

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

This could be re-phrased so it's more concise:

Using the two frameworks in a single file is supported. To do so, import both XCTest and Testing.

Copy link
Contributor

Choose a reason for hiding this comment

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

swift-testing is a package though, not a framework. So that may be confusing.

Choose a reason for hiding this comment

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

Replace framework with library. Since there are a lot of situations where those terms are used interchangeably in day-to-day work, that casualness slipped into my suggestion. Aside from that one word, I think that sentence is a better explanation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should I change to:

Using the two libraries in a single file is supported. To do so, import both XCTest and Testing.

?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think what we've got here is fine as-is. @SeanROlszewski how strongly do you feel about it?

Choose a reason for hiding this comment

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

Sounds good to me!

Copy link
Contributor

Choose a reason for hiding this comment

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

Great! @Sajjon If you're ready to merge, let me know.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@grynspan good to merge IMO.

What do I need to do? Update source branch with head? Rebase or merge main into source?

Looks like there are no conflicts so GitHub ought to be able to merge it as is (I m on GitHub iOS app currently so not as "glanceable")

Copy link
Contributor

Choose a reason for hiding this comment

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

I'll merge for you since you can't click the big green button yourself. :)

@briancroom
Copy link
Contributor

Thanks for the contribution, @Sajjon! I like this.

@grynspan
Copy link
Contributor

I am on vacation through the end of the year, so the rest of the team can assist you with landing this PR. Thanks again!

@grynspan grynspan added the documentation 📚 Improvements or additions to documentation label Jan 2, 2024
@grynspan grynspan merged commit ddcb574 into swiftlang:main Jan 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation 📚 Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants