<!--
{
  "availability" : [
    "iOS: 27.3.0 -",
    "iPadOS: 27.3.0 -",
    "macCatalyst: 27.3.0 -",
    "macOS: 27.3.0 -",
    "tvOS: 27.3.0 -",
    "visionOS: 27.3.0 -",
    "watchOS: 27.3.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppIntentsTesting",
  "identifier" : "/documentation/AppIntentsTesting/IntentValueExpectation/contains(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "App Intents Testing",
      "AppIntentsTesting"
    ],
    "preciseIdentifier" : "s:17AppIntentsTesting22IntentValueExpectationPA2A09PrimitiveF0VRszrlE8containsyAESSFZ"
  },
  "title" : "contains(_:)"
}
-->

# contains(_:)

Creates an expectation that requires the value to be a string that
contains a substring.

```
static func contains(_ substring: String) -> Self
```

## Parameters

`substring`

The text to search for in the string.

## Return Value

An expectation that searches a string value for `substring`.

## Discussion

The comparison is exact and case-sensitive. A value that isn’t a string
doesn’t satisfy the expectation.

---

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)