Testing Voice Assistants: Alexa, Google Assistant, and Siri Shortcuts
Voice interfaces break in ways that traditional UI testing completely misses. A user says "remind me at three" and your assistant hears "remind me at tree." Intent resolution fails silently. Multi-turn conversations lose context between turns. Wake word detection varies by room acoustics. If you are shipping a voice assistant or building Alexa skills and Google Actions, you need a dedicated testing strategy — and this guide walks through the tools and patterns that actually work in production.
Why Voice Testing Is Different
Testing a voice assistant is not just testing an API with audio input. Three distinct layers can fail independently:
- Automatic Speech Recognition (ASR) — converting audio to text
- Natural Language Understanding (NLU) — mapping text to intents and entities
- Dialog management and fulfillment — executing the right action and returning the right response
Most developers test layer 3 in isolation and ship. The failures that reach users almost always happen in layers 1 and 2. A solid test suite covers all three.
Testing Alexa Skills with ask-sdk-test
The ask-sdk-test library lets you write unit tests for Alexa skills without a live device or the Alexa simulator. It drives your skill handler directly with simulated request envelopes.
Installation
npm install --save-dev ask-sdk-testBasic Intent Handler Test
Suppose you have a skill that reads back the current weather. Here is a minimal test for the GetWeatherIntent:
const { SkillSettings, AlexaTest, IntentRequestBuilder } = require('ask-sdk-test');
const skill = require('../src/index'); // your skill entry point
const skillSettings = {
appId: 'amzn1.ask.skill.test-skill-id',
userId: 'amzn1.ask.account.test-user',
deviceId: 'amzn1.ask.device.test-device',
locale: 'en-US',
};
const alexaTest = new AlexaTest(skill.handler, skillSettings);
describe('GetWeatherIntent', () => {
it('returns the current temperature for a known city', async () => {
await alexaTest.test([
{
request: new IntentRequestBuilder(skillSettings, 'GetWeatherIntent')
.withSlotResolution('city', 'Seattle', 'cityId', 'seattle_wa')
.build(),
says: /the current temperature in Seattle is/i,
repromptsNothing: false,
shouldEndSession: false,
},
]);
});
it('prompts for city when slot is missing', async () => {
await alexaTest.test([
{
request: new IntentRequestBuilder(skillSettings, 'GetWeatherIntent').build(),
says: /which city would you like/i,
repromptsNothing: false,
shouldEndSession: false,
},
]);
});
});The says matcher accepts a string or regex. Keep it as a regex — exact string matching against TTS output is brittle and breaks on minor copy changes.
Multi-Turn Conversation Test
Dialog model skills require testing across turns. ask-sdk-test supports sequential turn arrays:
describe('Multi-turn weather dialog', () => {
it('collects city then date in two turns', async () => {
await alexaTest.test([
{
request: new IntentRequestBuilder(skillSettings, 'GetWeatherIntent').build(),
says: /which city/i,
shouldEndSession: false,
},
{
request: new IntentRequestBuilder(skillSettings, 'GetWeatherIntent')
.withSlotResolution('city', 'Portland', 'cityId', 'portland_or')
.build(),
says: /for which date/i,
shouldEndSession: false,
},
{
request: new IntentRequestBuilder(skillSettings, 'GetWeatherIntent')
.withSlotResolution('city', 'Portland', 'cityId', 'portland_or')
.withSlot('date', '2024-12-25')
.build(),
says: /on December 25/i,
shouldEndSession: true,
},
]);
});
});Each entry in the array represents one turn. Session attributes are automatically threaded between turns, matching what the Alexa service does in production.
Testing Google Actions with ActionsOnGoogleTestApp
Google's actions-on-google SDK ships a test utility called ActionsOnGoogleTestApp (previously ActionsOnGoogleTestApp from @assistant/conversation). For newer Actions SDK v3 projects, you drive tests against your fulfillment webhook directly.
Setting Up the Test Harness
const { conversation } = require('@assistant/conversation');
const { ActionsOnGoogleTestApp } = require('@assistant/conversation/test');
const app = conversation();
// Register your handlers (same as production entry point)
require('../src/handlers')(app);
const testApp = new ActionsOnGoogleTestApp({ app });Testing a Simple Intent
describe('Google Action — order coffee', () => {
it('confirms the order when size and type are provided', async () => {
const response = await testApp.send('I want a large oat milk latte');
expect(response.prompt.override).toBe(false);
expect(response.prompt.firstSimple.speech).toMatch(/your large oat milk latte/i);
expect(response.scene.next.name).toBe('OrderConfirmation');
});
it('asks for size when only type is provided', async () => {
const response = await testApp.send('I want a cappuccino');
expect(response.prompt.firstSimple.speech).toMatch(/what size/i);
expect(response.scene.next.name).toBe('CollectSize');
});
});Session Parameter Persistence
Multi-turn tests require you to thread session tokens manually:
it('remembers the drink type across turns', async () => {
const turn1 = await testApp.send('I want an espresso');
// scene expects size next
expect(turn1.scene.next.name).toBe('CollectSize');
// Pass the session token to continue the same conversation
const turn2 = await testApp.send('Make it a double', {
session: turn1.session,
});
expect(turn2.prompt.firstSimple.speech).toMatch(/double espresso/i);
});NLU Regression Testing in Python
NLU regression testing checks that your intent model still resolves correctly after retraining. The pattern: maintain a labeled test set of utterances, run them through the model, assert that precision and recall stay above thresholds.
Building an NLU Test Suite
import json
import pytest
from alexa_smapi import SkillManagementAPI # pip install ask-smapi-sdk
NLU_TEST_CASES = [
{"utterance": "what's the weather today", "expected_intent": "GetWeatherIntent"},
{"utterance": "how hot is it outside", "expected_intent": "GetWeatherIntent"},
{"utterance": "will it rain tomorrow", "expected_intent": "GetWeatherIntent"},
{"utterance": "set a timer for five minutes", "expected_intent": "SetTimerIntent"},
{"utterance": "remind me in an hour", "expected_intent": "SetReminderIntent"},
{"utterance": "cancel", "expected_intent": "AMAZON.CancelIntent"},
{"utterance": "never mind", "expected_intent": "AMAZON.CancelIntent"},
{"utterance": "help", "expected_intent": "AMAZON.HelpIntent"},
]
INTENT_ACCURACY_THRESHOLD = 0.95
@pytest.fixture(scope="session")
def nlu_client():
return SkillManagementAPI(
skill_id="amzn1.ask.skill.your-skill-id",
stage="development",
)
def test_intent_resolution_accuracy(nlu_client):
correct = 0
failures = []
for case in NLU_TEST_CASES:
result = nlu_client.call_skill_nlu(
utterance=case["utterance"],
locale="en-US",
)
predicted = result["selectedIntent"]["name"]
if predicted == case["expected_intent"]:
correct += 1
else:
failures.append({
"utterance": case["utterance"],
"expected": case["expected_intent"],
"got": predicted,
"confidence": result["selectedIntent"].get("confirmationStatus"),
})
accuracy = correct / len(NLU_TEST_CASES)
if failures:
print("\nNLU Failures:")
for f in failures:
print(f" '{f['utterance']}' → expected {f['expected']}, got {f['got']}")
assert accuracy >= INTENT_ACCURACY_THRESHOLD, (
f"NLU accuracy {accuracy:.1%} below threshold {INTENT_ACCURACY_THRESHOLD:.1%}. "
f"{len(failures)} utterance(s) misclassified."
)Run this suite before and after every model retrain. A drop below threshold blocks the deploy.
Virtual Device Testing
Unit tests cover handler logic but cannot catch issues in the ASR pipeline. Virtual device testing sends real audio (or TTS-synthesized audio) through the live skill invocation path.
Alexa Virtual Device with the AVS SDK
The Alexa Voice Service (AVS) SDK exposes a simulation API. The Alexa Skills Kit CLI wraps it:
# Install ASK CLI
npm install -g ask-cli
# Simulate a skill invocation end-to-end (text-in, audio-out)
ask smapi simulate-skill \
--skill-id amzn1.ask.skill.your-skill-id \
--input-content "open weather skill and tell me the forecast for tomorrow" \
--device-locale en-USFor programmatic use from a test suite:
const { StandardSmapiClientBuilder } = require('ask-smapi-sdk');
const client = new StandardSmapiClientBuilder()
.withRefreshTokenConfig({
clientId: process.env.ASK_CLIENT_ID,
clientSecret: process.env.ASK_CLIENT_SECRET,
refreshToken: process.env.ASK_REFRESH_TOKEN,
})
.client();
async function simulateUtterance(skillId, utterance, locale = 'en-US') {
const result = await client.simulateSkillV1(skillId, {
input: { content: utterance },
device: { locale },
});
// Poll for simulation result (async job)
let simulation;
do {
await new Promise(r => setTimeout(r, 1000));
simulation = await client.getSkillSimulationV1(skillId, result.id);
} while (simulation.status === 'IN_PROGRESS');
return simulation.result;
}
// In your test
it('end-to-end: weather skill returns spoken forecast', async () => {
const result = await simulateUtterance(
'amzn1.ask.skill.your-skill-id',
'ask weather skill for the Seattle forecast'
);
const spokenResponse = result.skillExecutionInfo.invocationResponse.body
.response.outputSpeech.ssml;
expect(spokenResponse).toMatch(/Seattle/i);
expect(spokenResponse).toMatch(/degrees/i);
}, 30000); // allow up to 30s for simulationWake Word Testing Strategies
Wake word detection is hardware and firmware dependent. You cannot fully replicate device behavior in software, but you can measure false acceptance and false rejection rates in controlled conditions.
False rejection (device misses a legitimate wake word) and false acceptance (device triggers on non-wake-word audio) both damage user trust. Measure them separately.
Approach: Audio Corpus Testing
Build a labeled audio corpus:
wake-word-corpus/
positive/ # utterances containing the wake word
close-mic/
far-mic/
noisy-background/
negative/ # utterances NOT containing the wake word
similar-sounding/ # "Alexa" vs "Alaska", "echo" vs "gecko"
background-tv/
silence/Run each file through a detection script and report rates:
import os
import subprocess
from pathlib import Path
WAKE_WORD = "alexa"
CORPUS_ROOT = Path("wake-word-corpus")
def run_detector(audio_path: Path) -> bool:
"""Call your wake word detector binary or API."""
result = subprocess.run(
["./wakeword-detector", "--model", "alexa_v2.tflite", str(audio_path)],
capture_output=True,
text=True,
)
return result.returncode == 0
def evaluate_corpus():
true_positives = false_negatives = true_negatives = false_positives = 0
for audio_file in (CORPUS_ROOT / "positive").rglob("*.wav"):
if run_detector(audio_file):
true_positives += 1
else:
false_negatives += 1
print(f"FALSE REJECTION: {audio_file}")
for audio_file in (CORPUS_ROOT / "negative").rglob("*.wav"):
if run_detector(audio_file):
false_positives += 1
print(f"FALSE ACCEPTANCE: {audio_file}")
else:
true_negatives += 1
total_positive = true_positives + false_negatives
total_negative = true_negatives + false_positives
recall = true_positives / total_positive if total_positive else 0
specificity = true_negatives / total_negative if total_negative else 0
print(f"\nWake Word Detection Results")
print(f" Recall (sensitivity): {recall:.1%} (target: >95%)")
print(f" Specificity: {specificity:.1%} (target: >99%)")
return recall >= 0.95 and specificity >= 0.99
if __name__ == "__main__":
passed = evaluate_corpus()
exit(0 if passed else 1)Run this corpus test before every firmware or model update. A regression in specificity means users' devices are triggering unexpectedly — a privacy-sensitive failure.
Siri Shortcuts Testing
Siri Shortcuts runs on-device and exposes no remote test API. Your testable surface is the INIntent handler — the AppIntentHandler (Swift) or the Python bridge if you are using SiriKit via a framework.
For Python-backed shortcuts using the shortcuts module or a companion app, test the intent handler in isolation:
import unittest
from unittest.mock import MagicMock, patch
from intents.reorder_coffee import ReorderCoffeeIntentHandler
class TestReorderCoffeeIntent(unittest.TestCase):
def setUp(self):
self.handler = ReorderCoffeeIntentHandler()
def test_reorders_last_order_when_confirmed(self):
intent = MagicMock()
intent.parameters = {"confirm": True}
with patch("intents.reorder_coffee.fetch_last_order") as mock_fetch, \
patch("intents.reorder_coffee.place_order") as mock_place:
mock_fetch.return_value = {"item": "oat latte", "size": "large"}
mock_place.return_value = {"order_id": "ORD-9988"}
result = self.handler.handle(intent)
mock_place.assert_called_once_with(item="oat latte", size="large")
self.assertIn("oat latte", result.speech_response)
self.assertIn("ORD-9988", result.speech_response)
def test_aborts_when_user_declines(self):
intent = MagicMock()
intent.parameters = {"confirm": False}
with patch("intents.reorder_coffee.place_order") as mock_place:
result = self.handler.handle(intent)
mock_place.assert_not_called()
self.assertIn("cancelled", result.speech_response.lower())For UI-level Siri testing on iOS, XCTest's XCSiriUITestCase lets you record and replay Siri interactions in the simulator. Keep these as smoke tests — they are slow and flaky on CI. Fast intent handler unit tests are your workhorse.
CI/CD Pipeline Integration
A recommended pipeline for an Alexa skill or Google Action:
# .github/workflows/voice-skill.yml
name: Voice Skill CI
on:
push:
branches: [main, develop]
pull_request:
jobs:
unit-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
- run: npm ci
- run: npm test
env:
NODE_ENV: test
nlu-regression:
runs-on: ubuntu-latest
needs: unit-tests
if: github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- run: pip install -r requirements-test.txt
- run: pytest tests/nlu/ -v --tb=short
env:
ASK_CLIENT_ID: ${{ secrets.ASK_CLIENT_ID }}
ASK_CLIENT_SECRET: ${{ secrets.ASK_CLIENT_SECRET }}
ASK_REFRESH_TOKEN: ${{ secrets.ASK_REFRESH_TOKEN }}
e2e-simulation:
runs-on: ubuntu-latest
needs: nlu-regression
if: github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
- run: npm ci
- run: npm run test:e2e
env:
ASK_CLIENT_ID: ${{ secrets.ASK_CLIENT_ID }}
ASK_CLIENT_SECRET: ${{ secrets.ASK_CLIENT_SECRET }}
ASK_REFRESH_TOKEN: ${{ secrets.ASK_REFRESH_TOKEN }}
SKILL_ID: ${{ secrets.SKILL_ID }}
timeout-minutes: 10Gate deployment on all three stages. NLU regression and E2E simulation only run on main — they are slow and consume API quota. Unit tests run on every push and PR, giving fast feedback during development.
Key Takeaways
Voice assistant testing has three non-negotiable pillars:
- Unit test your handlers with
ask-sdk-testorActionsOnGoogleTestApp. These run in milliseconds and catch fulfillment bugs before they ever reach a device. - NLU regression tests run on every model change. An accuracy drop of even two percentage points translates to real user frustration at scale.
- Virtual device simulation catches the gap between your handler logic and the live invocation path. Run these on every merge to main.
Wake word testing and Siri Shortcuts require additional tooling depending on your platform, but the principle is the same: build a labeled corpus, measure the metrics that matter (recall, specificity, intent accuracy), set thresholds, and block deploys that regress below them.
Voice is unforgiving. Users do not retry the way they click a button again. A single failed interaction is often a lost user. A test suite that covers all three layers is not optional — it is the minimum bar for shipping.