Swift Testing is a library for defining tests and recording attachable values that can be saved as part of a test run. You write tests with the Test type and group them into suites, expressing expectations through Expectation and Confirmation and reporting failures as Issue values that capture their SourceLocation. You refine how tests run by applying traits such as ConditionTrait, ParallelizationTrait, TimeLimitTrait, and Tag, and you attach diagnostic data by conforming to the Attachable protocol and saving an Attachment, including images via AttachableImageFormat. The library also supports exit tests through ExitTest and ExitStatus, and lets you customize how arguments and values are represented with CustomTestArgumentEncodable, CustomTestReflectable, and CustomTestStringConvertible.
Defining Tests and Suites 2
The core types that represent individual tests and the source locations they reference.
- StTestA type representing a test or suite.
- StSourceLocationA type representing a location in source code.
Checking Expectations 3
Types for validating conditions and confirming that expected events occur during a test.
- StExpectationA type describing an expectation that has been evaluated.
- StExpectationFailedErrorA type describing an error thrown when an expectation fails during
- StConfirmationA type that can be used to confirm that an event occurs zero or more times.
Reporting Issues 3
Types that capture and describe failures and other noteworthy events recorded during a test run.
- StIssueA type describing a failure or warning which occurred during a test.
- StCommentA type that represents a comment related to a test.
- StBugA type that represents a bug report tracked by a test.
Customizing Test Behavior with Traits 9
Traits and trait protocols that refine how, when, and in what scope tests and suites run.
- PrTraitA protocol describing traits that can be added to a test function or to a
- PrTestTraitA protocol describing a trait that you can add to a test function.
- PrSuiteTraitA protocol describing a trait that you can add to a test suite.
- PrTestScopingA protocol that tells the test runner to run custom code before or after it
- StConditionTraitA type that defines a condition which must be satisfied for the testing
- StParallelizationTraitA type that defines whether the testing library runs this test serially
- StTimeLimitTraitiOS 16.0+A type that defines a time limit to apply to a test.
- StIssueHandlingTraitA type that allows transforming or filtering the issues recorded by a test.
- StTagA type representing a tag that can be applied to a test.
Attaching Diagnostic Data 5
Protocols and types for saving values, wrappers, and images as attachments alongside a test run.
- PrAttachableA protocol describing a type whose instances can be recorded and saved as
- PrAttachableWrapperA protocol describing a type whose instances can be recorded and saved as
- PrAttachableAsImageiOS 14.0+A protocol describing images that can be converted to instances of
- StAttachmentA type describing values that can be attached to the output of a test run
- StAttachableImageFormatiOS 14.0+A type describing image formats supported by the system that can be used
Running Exit Tests 2
Types for running code in a separate process and inspecting how that process terminates.
- StExitTestA type describing an exit test.
- EnExitStatusAn enumeration describing possible status a process will report on exit.
Representing Arguments and Values 3
Protocols that customize how test arguments and values are encoded, reflected, and described.
- PrCustomTestArgumentEncodableA protocol for customizing how arguments passed to parameterized tests are
- PrCustomTestReflectableA protocol describing types with a custom reflection when presented as part
- PrCustomTestStringConvertibleA protocol describing types with a custom string representation when
Type Aliases 1
- TyKnownIssueMatcherA function that is used to match known issues.