Hello everyone! One of the features of swift-testing is a test trait that allows associating a tag with a test suite or test function. Currently there are two ways to express this trait: symbolically or with a string literal. We are removing the string literal definition of tags because as we adopt swift-testing, we've found it to be more useful to have a consistent set of well-defined tags used throughout our code.
For more background on string literal tags check out Rethinking symbolic vs. string literal tags.
Problem
A test author can associate a tag with a test or suite using the .tags()
trait, to which they pass an already defined tag or a string literal to the tag. It's confusing to figure out which tests have certain tags when they are defined with string literals.
Proposed solution
We are removing string literal tag definitions because we have found it more clear and useful to define a tag in a specific place in code and have all the tests with that tag refer to the already defined tag.
Now test authors will define tags symbolically.
Test authors who are currently using string literal tags can update their test definitions to use symbolic tags similar to the following:
// String literal tag
@Test(.tags("tagFoo")) func example() { }
->
// Symbolic tag
extension Tag {
@Tag static var tagFoo: Tag
}
@Test(.tags(.tagFoo)) func example() { }
Source compatibility
This change will be breaking for test authors who have already adopted string literal tag definitions in their test signatures.