Skip to content

Commit 74a0cbd

Browse files
Updates to articles to conform to some documentation style. (#344)
Updates to articles to conform to some style guidelines: - Begin an article title with a gerund - Start section headings with an imperative verb. - Remove some symbols references that already exist alongside these articles in collection topic groups. Part 3 of changes for rdar://119702877 ### 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. --------- Co-authored-by: Chuck Toporek <[email protected]>
1 parent 7262462 commit 74a0cbd

10 files changed

+55
-118
lines changed

Sources/Testing/Testing.docc/AddingComments.md

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Seeing comments related to tests in these contexts can help diagnose issues more
2828
quickly. Comments can be added to test declarations and the testing library will
2929
automatically capture and show them when issues are recorded.
3030

31-
## Adding a code comment to a test
31+
## Add a code comment to a test
3232

3333
To include a comment on a test or suite, write an ordinary Swift code comment
3434
immediately before its `@Test` or `@Suite` attribute:
@@ -67,7 +67,7 @@ includes an example code snippet or diagram.
6767
<!-- FIXME: Uncomment this section if/when the `.comment(...)` trait is promoted
6868
to non-experimental SPI
6969
70-
## Adding a comment to a test programmatically
70+
## Add a comment programmatically
7171
7272
For more precise control over a comment's content, comments can be added to a
7373
test programmatically by explicitly specifying them as trait arguments to the
@@ -86,7 +86,7 @@ func lunchMenu() {
8686
}
8787
``` -->
8888

89-
## Using test comments effectively
89+
## Use test comments effectively
9090

9191
As in normal code, comments on tests are generally most useful when:
9292

@@ -95,11 +95,3 @@ As in normal code, comments on tests are generally most useful when:
9595

9696
If a test is related to a bug or issue, consider using the ``Bug`` trait instead
9797
of comments. For more information, review <doc:AssociatingBugs>.
98-
99-
100-
## Topics
101-
102-
- ``Comment``
103-
<!-- FIXME: Uncomment this section if/when the `.comment(...)` trait is promoted
104-
to non-experimental SPI.
105-
- ``Trait/comment(_:)`` -->

Sources/Testing/Testing.docc/AddingTags.md

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ See https://swift.org/LICENSE.txt for license information
1010
See https://swift.org/CONTRIBUTORS.txt for Swift project authors
1111
-->
1212

13-
Add tags to tests and customize their appearance.
13+
Use tags to provide semantic information for organization, filtering, and customizing appearances.
1414

1515
## Overview
1616

@@ -24,7 +24,7 @@ functions at the source level, while tags provide semantic information for a
2424
test that can be shared with any number of other tests across test suites,
2525
source files, and even test targets.
2626

27-
## Adding tags
27+
## Add a tag
2828

2929
To add a tag to a test, use the ``Trait/tags(_:)-505n9`` trait. This trait takes
3030
a sequence of tags as its argument, and those tags are then applied to the
@@ -120,7 +120,7 @@ any test target and applied to any test:
120120
The testing library does not assign any semantic meaning to these tags, nor does
121121
the presence or absence of these tags affect how the testing library runs tests.
122122

123-
## Customizing a tag's appearance
123+
## Customize a tag's appearance
124124

125125
By default, a tag does not appear in a test's output when the test is run. It is
126126
possible to assign colors to tags defined in a package so that when the test is
@@ -155,11 +155,3 @@ be set to:
155155
".legallyRequired": "#66FFCC"
156156
}
157157
```
158-
159-
## Topics
160-
161-
- ``Trait/tags(_:)-505n9``
162-
- ``Trait/tags(_:)-yg0i``
163-
- ``Tag``
164-
- ``Tag/List``
165-
- ``Tag()``

Sources/Testing/Testing.docc/AssociatingBugs.md

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ specific bugs with tests that reproduce them or verify they are fixed.
2323
"issues." To avoid confusion with the ``Issue`` type in the testing library,
2424
this document consistently refers to them as "bugs."
2525

26-
## Associating a bug with a test
26+
## Associate a bug with a test
2727

2828
To associate a bug with a test, use the ``Trait/bug(_:relationship:_:)-86mmm``
2929
or ``Trait/bug(_:relationship:_:)-3hsi5`` function. The first argument to this
@@ -43,7 +43,7 @@ specified as a string, it must be parseable as an unsigned integer or as a URL.
4343
For more information on the formats recognized by the testing library, see
4444
<doc:BugIdentifiers>.
4545

46-
## Specifying the relationship between a bug and a test
46+
## Specify the relationship between a bug and a test
4747

4848
By default, the nature of the relationship between a bug and a test is
4949
unspecified. All the testing library knows about such relationships is that they
@@ -101,10 +101,3 @@ func hasNapkins() async {
101101
...
102102
}
103103
```
104-
105-
## Topics
106-
107-
- <doc:BugIdentifiers>
108-
- ``Trait/bug(_:relationship:_:)-86mmm``
109-
- ``Trait/bug(_:relationship:_:)-3hsi5``
110-
- ``Bug``

Sources/Testing/Testing.docc/DefiningTests.md

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ This article assumes that the package or project being tested has already been
2020
configured with a test target. For help configuring a package to use the testing
2121
library, see <doc:TemporaryGettingStarted>.
2222

23-
## Importing the testing library
23+
## Import the testing library
2424

2525
To import the testing library, add the following to the Swift source file that
26-
will contain the test:
26+
contains the test:
2727

2828
```swift
2929
import Testing
@@ -33,11 +33,11 @@ import Testing
3333
testing library into an application, library, or binary target is not
3434
supported or recommended. Test functions are not stripped from binaries when
3535
building for release, so logic and fixtures of a test may be visible to anyone
36-
who inspects a build product containing a test function.
36+
who inspects a build product that contains a test function.
3737

38-
## Declaring a test function
38+
## Declare a test function
3939

40-
To declare a test function, write a Swift function declaration that does not
40+
To declare a test function, write a Swift function declaration that doesn't
4141
take any arguments, then prefix its name with the `@Test` attribute:
4242

4343
```swift
@@ -55,7 +55,7 @@ Note that, while this function is a valid test function, it does not actually
5555
perform any action or test any code. To check for expected values and outcomes
5656
in test functions, add [expectations](doc:Expectations) to the test function.
5757

58-
## Customizing a test's name
58+
## Customize a test's name
5959

6060
To customize a test function's name as presented in an IDE or at the command
6161
line, supply a string literal as an argument to the `@Test` attribute:
@@ -78,7 +78,7 @@ the process), it can be annotated `@MainActor`:
7878
@Test @MainActor func foodTruckExists() async throws { ... }
7979
```
8080

81-
## Limiting the availability of a test
81+
## Limit the availability of a test
8282

8383
If a test function can only run on newer versions of an operating system or of
8484
the Swift language, use the `@available` attribute when declaring it. Use the
@@ -90,13 +90,3 @@ a test is unable to run due to limited availability:
9090
@available(swift, introduced: 8.0, message: "Requires Swift 8.0 features to run")
9191
@Test func foodTruckExists() { ... }
9292
```
93-
94-
## Topics
95-
96-
- ``Test``
97-
- ``Test(_:_:)``
98-
99-
## See Also
100-
101-
- <doc:Expectations>
102-
- <doc:ParameterizedTesting>

Sources/Testing/Testing.docc/EnablingAndDisabling.md

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ automatically skip them if conditions like these are not met.
2222

2323
- Note: A condition may be evaluated multiple times during testing.
2424

25-
## Disabling a test
25+
## Disable a test
2626

27-
If a test should be disabled unconditionally, you can use the
27+
If you need to disable a test unconditionally, use the
2828
``Trait/disabled(_:fileID:filePath:line:column:)`` function. Given the following
2929
test function:
3030

@@ -42,17 +42,17 @@ func sellsBurritos() async throws { ... }
4242

4343
The test will now always be skipped.
4444

45-
It is also possible to add a comment to the trait that will be presented in the
46-
output from the runner when it skips the test:
45+
It is also possible to add a comment to the trait to present in the output from
46+
the runner when it skips the test:
4747

4848
```swift
4949
@Test("Food truck sells burritos", .disabled("We only sell Thai cuisine"))
5050
func sellsBurritos() async throws { ... }
5151
```
5252

53-
## Conditionally enabling or disabling a test
53+
## Conditionally enable or disable a test
5454

55-
Sometimes, it makes sense to enable a test only if a condition is met. Consider
55+
Sometimes, it makes sense to enable a test only when a certain condition is met. Consider
5656
the following test function:
5757

5858
```swift
@@ -98,10 +98,10 @@ func isCold() async throws { ... }
9898
```
9999

100100
If a test has multiple conditions applied to it, they must _all_ pass for it to
101-
run. Otherwise, the first condition to fail will be noted as the reason the test
102-
was skipped.
101+
run. Otherwise, the test notes the first condition to fail as the reason the test
102+
is skipped.
103103

104-
## Handling complex conditions
104+
## Handle complex conditions
105105

106106
If a condition is complex, consider factoring it out into a helper function to
107107
improve readability:
@@ -116,12 +116,3 @@ func allIngredientsAvailable(for food: Food) -> Bool { ... }
116116
)
117117
func makeSundae() async throws { ... }
118118
```
119-
120-
## Topics
121-
122-
- ``Trait/enabled(if:_:fileID:filePath:line:column:)``
123-
- ``Trait/enabled(_:fileID:filePath:line:column:_:)``
124-
- ``Trait/disabled(_:fileID:filePath:line:column:)``
125-
- ``Trait/disabled(if:_:fileID:filePath:line:column:)``
126-
- ``Trait/disabled(_:fileID:filePath:line:column:_:)``
127-
- ``ConditionTrait``

Sources/Testing/Testing.docc/LimitingExecutionTime.md

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Limiting the execution time of a test
1+
# Limiting the running time of tests
22

33
<!--
44
This source file is part of the Swift.org open source project
@@ -59,8 +59,3 @@ test functions and child test suites within that suite.
5959
When a time limit is applied to a parameterized test function, it is applied to
6060
each invocation _separately_ so that if only some arguments cause failures, then
6161
successful arguments are not incorrectly marked as failing too.
62-
63-
## Topics
64-
65-
- ``Trait/timeLimit(_:)``
66-
- ``TimeLimitTrait``

Sources/Testing/Testing.docc/MigratingFromXCTest.md

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ The testing library provides much of the same functionality of XCTest, but uses
2121
its own syntax to declare test functions and types. This document covers the
2222
process of converting XCTest-based content to use the testing library instead.
2323

24-
### Adding the testing library as a dependency
24+
### Add the testing library as a dependency
2525

2626
Before the testing library can be used, it must be added as a dependency of your
2727
Swift package or Xcode project. For more information on how to add it, see the
2828
[Getting Started](doc:TemporaryGettingStarted) guide.
2929

30-
### Importing the testing library
30+
### Import the testing library
3131

3232
XCTest and the testing library are available from different modules. Instead of
3333
importing the XCTest module, import the Testing module:
@@ -51,7 +51,7 @@ A single source file can contain tests written with XCTest as well as other
5151
tests written with the testing library. Import both XCTest and Testing if a
5252
source file contains mixed test content.
5353

54-
### Converting test classes
54+
### Convert test classes
5555

5656
XCTest groups related sets of test methods in test classes: classes that inherit
5757
from the [`XCTestCase`](https://developer.apple.com/documentation/xctest/xctestcase)
@@ -92,7 +92,7 @@ If you use a class as a test suite, it must be declared `final`.
9292
For more information about suites and how to declare and customize them, see
9393
<doc:OrganizingTests>.
9494

95-
#### Converting setUp() and tearDown() functions
95+
### Convert setup and teardown functions
9696

9797
In XCTest, code can be scheduled to run before and after a test using the
9898
[`setUp()`](https://developer.apple.com/documentation/xctest/xctest/3856481-setup)
@@ -169,7 +169,7 @@ implement `deinit`:
169169
((103616215)[rdar://103616215])
170170
-->
171171

172-
### Converting test methods
172+
### Convert test methods
173173

174174
The testing library represents individual tests as functions, similar to how
175175
they are represented in XCTest. However, the syntax for declaring a test
@@ -212,7 +212,7 @@ and/or `throws` and to be isolated to a global actor (for example, by using the
212212
For more information about test functions and how to declare and customize them,
213213
see <doc:DefiningTests>.
214214

215-
#### Converting XCTAssert() XCTUnwrap(), and XCTFail() calls
215+
### Check for expected values and outcomes
216216

217217
XCTest uses a family of approximately 40 functions to assert test requirements.
218218
These functions are collectively referred to as
@@ -255,6 +255,8 @@ error if its condition is not met:
255255
}
256256
}
257257

258+
### Check for optional values
259+
258260
XCTest also has a function, [`XCTUnwrap()`](https://developer.apple.com/documentation/xctest/3380195-xctunwrap),
259261
that tests if an optional value is `nil` and throws an error if it is. When
260262
using the testing library, you can use ``require(_:_:sourceLocation:)-6w9oo``
@@ -289,6 +291,8 @@ with optional expressions to unwrap them:
289291
}
290292
}
291293

294+
### Record issues
295+
292296
Finally, XCTest has a function, [`XCTFail()`](https://developer.apple.com/documentation/xctest/1500970-xctfail),
293297
that causes a test to fail immediately and unconditionally. This function is
294298
useful when the syntax of the language prevents the use of an `XCTAssert()`
@@ -355,7 +359,7 @@ their equivalents in the testing library:
355359
| `try XCTUnwrap(x)` | `try #require(x)` |
356360
| `XCTFail("…")` | `Issue.record("…")` |
357361

358-
#### Continuing or halting after test failures
362+
### Continue or halt after test failures
359363

360364
An instance of an `XCTestCase` subclass can set its
361365
[`continueAfterFailure`](https://developer.apple.com/documentation/xctest/xctestcase/1496260-continueafterfailure)
@@ -407,7 +411,7 @@ When using either `continueAfterFailure` or
407411
``require(_:_:sourceLocation:)-5l63q``, other tests will continue to run after
408412
the failed test method or test function.
409413

410-
#### Converting XCTestExpectation and XCTWaiter
414+
### Validate asynchronous behaviors
411415

412416
XCTest has a class, [`XCTestExpectation`](https://developer.apple.com/documentation/xctest/xctestexpectation),
413417
that represents some asynchronous condition. A developer creates an instance of
@@ -478,7 +482,7 @@ recorded otherwise:
478482
}
479483
}
480484

481-
#### Converting XCTSkip(), XCTSkipIf(), and XCTSkipUnless() calls
485+
### Control whether a test runs
482486

483487
When using XCTest, the [`XCTSkip`](https://developer.apple.com/documentation/xctest/xctskip)
484488
error type can be thrown to bypass the remainder of a test function. As well,
@@ -518,7 +522,7 @@ test function with an instance of this trait type to control whether it runs:
518522
}
519523
}
520524

521-
#### Converting XCTExpectFailure() calls
525+
### Annotate known issues
522526

523527
A test may have a known issue that sometimes or always prevents it from passing.
524528
When written using XCTest, such tests can call
@@ -677,3 +681,4 @@ of issues:
677681
- <doc:DefiningTests>
678682
- <doc:OrganizingTests>
679683
- <doc:Expectations>
684+
- <doc:known-issues>

Sources/Testing/Testing.docc/OrganizingTests.md

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Organizing tests
1+
# Organizing test functions with suite types
22

33
<!--
44
This source file is part of the Swift.org open source project
@@ -39,7 +39,7 @@ within the scope of the outer test suite type.
3939
By default, tests contained within a suite will run in parallel with each other.
4040
For more information about test parallelization, see <doc:Parallelization>.
4141

42-
## Customizing a suite's name
42+
## Customize a suite's name
4343

4444
To customize a test suite's name, supply a string literal as an argument to the
4545
`@Suite` attribute:
@@ -162,7 +162,3 @@ class, but it must be declared `final`:
162162
actor CashRegisterTests: NSObject { ... } // ✅ OK: actors are implicitly final
163163
class MenuItemTests { ... } // ❌ ERROR: this class is not final
164164
```
165-
166-
## Topics
167-
168-
- ``Suite(_:_:)``

Sources/Testing/Testing.docc/Parallelization.md

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Parallelizing test execution
1+
# Running tests serially or in parallel
22

33
<!--
44
This source file is part of the Swift.org open source project
@@ -65,8 +65,3 @@ disabled (by, for example, passing `--no-parallel` to the `swift test` command.)
6565
- ``Trait/serial``
6666
- ``SerialTrait``
6767
-->
68-
69-
## See Also
70-
71-
- <doc:OrganizingTests>
72-
- <doc:ParameterizedTesting>

0 commit comments

Comments
 (0)