UserTurn
A single utterance a person says, with what you expect Siri to do in response.
Declaration
struct UserTurnOverview
A user turn is one thing the person says to Siri. Create a turn with only an utterance to give Siri context for a later turn, or add a closure of expectations to check what Siri does in response. A turn accepts Calls, Finds, OnScreen, Loads, and SiriResponse expectations. It compares them only with that turn, so something Siri does in another turn can’t satisfy them.
Each turn has an id. After a run, the framework matches each action Siri performs to its turn by identifier. A run that stops early never checks one turn’s expectations against another turn.
The following shows a turn that expects Siri to start a science quiz, not to create a reminder, and to include the name of the topic in its reply:
let quizExampleIntents = IntentDefinitions(bundleIdentifier: "com.example.QuizExample")
let startQuizIntent = quizExampleIntents.intents["StartQuizIntent"]
let createQuizReminderIntent = quizExampleIntents.intents["CreateQuizReminderIntent"]
UserTurn("In QuizExample, start a science quiz with 5 questions") {
Calls {
startQuizIntent
.expect(topic: .equals("Science"))
}
// Fails if Siri runs or asks the person to confirm the intent.
Calls(.disallowed) {
createQuizReminderIntent
}
// Checks if the reply names the topic.
SiriResponse(.contains("Science"))
}Place turns in a SiriScenario to run them as a conversation.