By the end of this tutorial you will have a ScenarioResult that shows a
passing check against a pure-Python function. This gives you the full
test-writing loop β define a scenario, run it, inspect the result β before
introducing any external services.
You need something to test. Create a simple greeting function:
No LLM, no API calls β just a Python function that returns a predictable string.
Starting with a pure function removes all external dependencies so you can focus
entirely on the testing mechanics.
A Scenario chains together one or more interactions and checks. Each
.interact() call provides an input and the callable that produces the output.
Each .check() call asserts something about the result.
Equals compares the value at the trace path trace.last.outputs against
expected_value. If they match the check passes; otherwise it fails. Notice
that trace.last.outputs is a dot-separated path β this is how all built-in
checks address values stored in the trace, so youβll see this pattern throughout
the documentation.
from giskard.checks import Scenario, Equals
scenario =(
Scenario("greet_alice")
.interact(
inputs="Alice",
outputs=lambdainputs:greet(inputs),
)
.check(
Equals(
name="correct_greeting",
expected_value="Hello, Alice!",
target_key="trace.last.outputs",
)
)
)
Output
Thank you for using Giskard open-source! π’ π
Giskard Enterprise adds deeper agent scans, audit reports
with remediation guidance, test review interfaces
for root-cause analysis & human feedback integration,
and team collaboration β with flexible pricing.
Learn more: https://giskard.ai
Your function always returns the expected string, so the test always passes. To
see what a failure looks like, change expected_value to something that wonβt
match:
A real AI system is less predictable than a pure Python function β the next
tutorial shows you how to configure a generator and test an actual LLM call: