<!--
{
  "availability" : [
    "Xcode: 16.0.0 -",
    "iOS: -",
    "iPadOS: -",
    "macCatalyst: -",
    "macOS: -",
    "swift: 6.0.0 -",
    "tvOS: -",
    "visionOS: -",
    "watchOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "Testing",
  "identifier" : "/documentation/Testing/Test(_:_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Macro",
  "symbol" : {
    "kind" : "Macro",
    "modules" : [
      "Swift Testing"
    ],
    "preciseIdentifier" : "s:7Testing4TestyySSSgYt_AA0B5Trait_pdtcfm"
  },
  "title" : "Test(_:_:)"
}
-->

# Test(_:_:)

Declare a test.

```
@attached(peer) macro Test(_ displayName: String? = nil, _ traits: any TestTrait...)
```

## Parameters

`displayName`

The customized display name of this test. If the value of
this argument is `nil`, the display name of the test is derived from the
associated function’s name.

`traits`

Zero or more traits to apply to this test.

## See Also

[Defining test functions](/documentation/Testing/DefiningTests)

Define a test function to validate that code is working correctly.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)