Part 8: Extension Cases — Testing Error Paths
Permalink to Part 8: Extension Cases — Testing Error PathsMost features have one happy path and many error paths. Instead of duplicating the entire use case, use extension cases to branch off from a parent:
# register-error-missing-email.uc.yaml
id: register-error-missing-email
title: 'Register — Missing Email Error'
extends: register-success
type: negative
description: 'Verify proper error handling when email is left blank'
preconditions: []
data:
email: '' # Override parent's email with empty string
# Replace steps starting at step index 14 (the "Fill in email" section)
# Count from 1 — this replaces from that step onward
steps_override:
from_step: 14
steps:
# Skip filling in email, go straight to submit
- 'locate: field "Password"'
- 'focus: field "Password"'
- 'enter: field "Password" value "{{ password }}"'
- 'locate: checkbox "I agree to the Terms of Service"'
- 'select: checkbox "I agree to the Terms of Service"'
- 'locate: button "Create Account"'
- 'focus: button "Create Account"'
- 'activate: button "Create Account"'
# Verify error handling
- 'verify: alert "Please correct the errors below"'
- 'verify: field_error "Email"'
- 'verify: focus field "Email"'
How Extension Cases Work
Permalink to How Extension Cases Work- The runner loads the parent case (
register-success) - It replaces the parent's
datavalues with any overrides you provide - It takes the parent's steps up to
from_step(exclusive), then appends yoursteps_override.steps - The resulting merged case runs as a single test
This is efficient for testing multiple validation scenarios — each extension case only defines what's different.