# This example demonstrates advanced terminal output matchers in choreo.
feature "Advanced Terminal Matchers"
setting: shell_path = "/bin/bash"
actor Terminal
scenario "Verifying precise terminal output" {
test StartsWith "output_starts_with matches the beginning of the output" {
given:
Test can_start
System log "${TEST2}"
System log "${TEST_LIST[2]}"
System log "${TEST_ARRAY.NAME}"
when:
Terminal run "echo 'Hello Choreo World'"
then:
Terminal last_command succeeded
Terminal output_starts_with 'Hello'
}
test CheckAppVersion "Check application version" {
given:
# Conditions that must be met before the test runs.
Test has_succeeded StartsWith
when:
# Actions to be performed.
Terminal run "echo 'my-app version 1.0.0'"
then:
# Conditions that must be true after the actions.
Terminal last_command succeeded
Terminal output_contains "my-app version"
}
test CreateAndCapture "Create a resource and capture its ID" {
given:
# This test depends on the success of the previous one.
Test has_succeeded CheckAppVersion
when:
Terminal run "echo 'Created resource with ID: res-123'"
then:
# Capture part of the output into a variable named 'resourceId'.
Terminal output_matches "Created resource with ID: (res-\d+)" as resourceId
}
# This block runs after all tests in the scenario are complete.
after {
# Use the captured 'resourceId' variable to clean up.
Terminal run "echo 'Cleaning up ${resourceId}'"
}
}