How to Test AI Applications: Why AI Testing Is Different

So far, you have used AI to help you test. Now you will test AI itself. This lesson explains how to test AI applications, why an exact expected result often stops working and which skills you already have that still apply. Your testing mindset matters more here than ever.

Advertisement

📖 What You’ll Learn

  • How AI products differ from normal software
  • Why exact-match checks often fail
  • Which layers of an AI product you can test
  • The new kinds of risk that AI adds

💡 How to Test AI Applications: What Changes

Explain Like I’m 5: A New Kind of Test

Imagine: A maths quiz has one right answer. A story-writing test has many good answers, and a few bad ones.

What it really means: AI answers need to be judged against rules, not matched word for word.

In testing: A chatbot can answer correctly in many different ways.

Remember from How LLMs Work that output can vary between runs. A correct answer can use different words every time.

Normal featureAI feature
One exact expected resultA range of acceptable answers
Same input gives same outputSame input can give different output
Pass or fail per runScores across many examples
Bugs live in codeProblems can also come from prompts, data or the model

🔍 Why Exact Matching Breaks

This small Python example compares an exact check with a check for the important fact.

expected = "Your order ships in 3 days."
answers = [
    "Your order ships in 3 days.",
    "Expect your parcel within 3 days.",
]

for answer in answers:
    print(answer == expected, "3 days" in answer)
True True
False True

Both answers are correct for a customer. The exact check fails one of them, while the fact check passes both. Real evaluation goes further, but the idea is the same: define what must be true, and not the exact words.


🧩 Test the Layers

Explain Like I’m 5: Testing a Sandwich

Imagine: If a sandwich tastes bad, you check the bread, the filling and the sauce one by one.

What it really means: An AI product has several layers, and each can be tested.

In testing: Many failures come from around the model, not from the model.

LayerExample checkType of test
User interfaceThe answer displays correctlyNormal UI test
APIErrors and timeouts are handledNormal API test
Prompt templateVariables are filled in correctlyNormal unit test
Retrieved documentsThe right document is foundRetrieval evaluation
Model answerThe answer is correct and safeAI evaluation
GuardrailsBanned content is blockedRule-based and AI checks

Good news: many of those layers can be tested with the skills you already have from Level 4.


🛠️ New Kinds of Risk

Explain Like I’m 5: A Very Confident Friend

Imagine: A friend answers every question boldly, even when guessing. You love them, but you check before believing them.

What it really means: AI can be wrong, biased or tricked while sounding sure.

In testing: A chatbot may invent a refund policy.

  • Hallucination: it states something false
  • Prompt injection: hidden text changes its behaviour
  • Data leakage: it reveals private information
  • Bias: it treats groups of people unfairly
  • Drift: quality changes after a model or data update

You will test each of these later in this level.

Hard rules can still be strict

Variable output does not mean anything goes. “Never share another customer’s data” is a pass or fail rule, and a single failure matters.


🌍 Real-Life Example: A Returns Chatbot

A shop adds a chatbot that answers returns questions. The policy allows 30 days.

AnswerVerdict
“You have 30 days to return it.”Pass
“Returns are accepted within a month of purchase.”Check: is a month the same as 30 days?
“You have 60 days.”Fail: wrong fact
“Sure, return it any time!”Fail: invented policy

The second answer shows why human judgment still matters. A tester has to decide if it is acceptable, then make that rule clear.


🧪 Try It Yourself

  1. Think of a chatbot on a website you use.
  2. Write one question you would ask it.
  3. Run the prompt below in three new chats.
  4. Mark each answer as pass, fail or unclear.
  5. Write the rule that would make your “unclear” answers easy to judge.

📋 Ready-to-Copy Prompt

You are a senior QA engineer learning to test AI features.

AI feature: [what it does]
Who uses it: [users]
Business rules: [rules]

Create a table of 8 acceptance rules for this feature.
For each rule, give: Rule, Must Always Be True or Must Never Happen,
Example Pass, Example Fail, How It Could Be Checked.

Use only the details above. List anything unclear as questions.

⚠️ Common Mistakes

  • Using exact text matches for every AI answer
  • Testing only the model and ignoring the layers around it
  • Saying “AI is unpredictable, so we cannot test it”
  • Running one example and calling the feature good
  • Treating safety rules as if they were flexible

🎯 Key Takeaways

  • AI answers are judged against rules, not exact text.
  • Quality is measured across many examples.
  • Many layers can still be tested in the usual way.
  • Some rules, especially safety rules, stay strict.

🎤 Interview Questions

1. How is testing an AI application different from testing normal software?

Model answer: Output can vary, and several answers may be correct. I define acceptance criteria and evaluate across many examples. I also test the surrounding layers normally, and I add checks for hallucination, safety, data leakage and drift.

2. Why do exact string assertions often fail for LLM features?

Model answer: The model can express the same correct meaning in different words, so exact matches give false failures. I check required facts, structure and rules, and I use semantic or human review where meaning matters.

3. Which parts of an LLM application can you test deterministically?

Model answer: I can test the UI, APIs, error handling, prompt construction, output parsing, access control and some guardrails with normal assertions. Those layers often cause real production failures.

4. What are the main risks in an AI feature?

Model answer: The main risks include hallucination, prompt injection, data leakage, bias, unsafe content and quality drift after updates. The priority depends on the domain and potential harm.

5. How would you define a pass for a chatbot answer?

Model answer: I would list required facts, forbidden content, tone and format, with agreed rules for borderline cases. I would then measure results across a representative set, with strict limits for critical safety rules.


📝 Assignment

Choose an AI feature you know. Divide it into layers, then write one test idea for each. Mark which ones can use exact checks and which need evaluation or human judgment.


❓ FAQ

Do I need to understand machine learning maths?

No. You need clear rules, good examples and careful measurement, which are all testing skills.

Can I test an AI feature I did not build?

Yes. You can test its behaviour from the outside. Access to prompts and logs makes diagnosis easier.


🚀 Next Steps

Well done on finishing this lesson. Complete the assignment, then continue with LLM Test Strategy: How to Test a Chatbot or AI Feature.