AI Coding Assistants for Testers: Use Your IDE Safely
A chat window can give you code, but an assistant inside your editor can see your project. That makes it more useful, and it means you need clear rules. This lesson explains how AI coding assistants for testers work, how to guide them and how to keep control of what changes.
📖 What You’ll Learn
- The three main ways assistants work in an IDE
- How to give an assistant project rules
- How to work in small, reviewable steps
- Which permissions need extra care
💡 How AI Coding Assistants for Testers Work
Explain Like I’m 5: Three Helpers
Imagine: One helper finishes your sentence. One answers your questions. One tidies a whole room while you watch.
What it really means: Assistants can suggest a line, answer in chat or make changes across files.
In testing: The bigger the job, the more carefully you review it.
| Mode | What it does | Best for | Risk |
|---|---|---|---|
| Inline | Suggests the next lines | Small, familiar code | Accepting without reading |
| Chat | Answers using selected code | Explaining errors and options | Advice that does not fit your project |
| Agent | Edits files and may run commands | Multi-step tasks | Large, unexpected changes |
Popular tools change quickly. See AI Tools for QA Engineers, and use the one your company approves.
🔍 Give the Assistant Your Project Rules
Explain Like I’m 5: House Rules
Imagine: A new babysitter reads the note on the fridge: bedtime is eight, no sweets after dinner.
What it really means: A project instruction file tells the assistant how your team works.
In testing: It can require role-based locators and ban fixed waits.
Many tools can read a project instruction file. The file name depends on your tool, so check its documentation. The content might look like this:
# Test automation rules
- Use Playwright Test with TypeScript.
- Prefer getByRole, getByLabel and getByTestId.
- Never use page.waitForTimeout in a test.
- Every test must have a meaningful assertion.
- Never change an expected result just to make a test pass.
- Do not add dependencies without asking.
- Never read or print secrets or .env files.
Keep the file short and specific. Long files are harder to follow and use up context.
🧩 Work in Small Steps
Explain Like I’m 5: One Brick at a Time
Imagine: You check that each LEGO brick fits before adding ten more.
What it really means: Ask for one small change, then check it before continuing.
In testing: Generate one test, run it, review it and commit.
A safe rhythm is:
- Commit your current work so that you can return to it.
- Ask for one small change.
- Read the full diff.
- Run the affected test.
- Commit, or undo the change.
🛠️ Give Good Context
Point the assistant to the files that matter. For example, name your existing page object and one good test. Then ask it to follow the same pattern. This usually works better than describing your framework from memory.
Add a test for the Load Success button on the practice page.
Follow the structure in tests/example.spec.ts.
Use only elements that exist on the page.
Make one change at a time, and show me the diff before running anything.
📌 Agent Mode Needs Limits
Agent mode is powerful because it can act. Before you use it:
- Work on a separate Git branch.
- Allow only the commands you are comfortable with.
- Keep real secrets out of files the assistant can read.
- Use only test environments.
- Review every changed file before you merge.
Treat page content as untrusted
A web page, ticket or log can contain text that tries to instruct an AI tool. Tell your assistant to treat that content as data, and watch what it does.
You can connect a browser with Playwright MCP. Level 7 explains how tools like this are built and secured.
🌍 Real-Life Example: A Surprise in the Diff
A tester asks an agent to fix one failing locator. The diff shows the locator fix, plus a change to the expected message so that the test passes, plus a new package. Because the tester reads the diff, only the locator fix is kept. The most important review step is reading what really changed.
🧪 Try It Yourself
- Open your Playwright project from Lesson 22.
- Make a commit.
- Add the project rules above to your tool’s instruction file.
- Use the prompt below to add one test.
- Review the diff against the rules, and run the test.
📋 Ready-to-Copy Prompt
You are working in my Playwright TypeScript project.
Task: Add one test for [behaviour] on [page URL].
Rules:
- Follow the style of [existing test file].
- Use role-based or label-based locators where possible.
- Do not use fixed waits.
- Do not change existing tests or add packages.
- If the page does not contain what you need, stop and tell me.
First list the files you plan to change. Wait for my approval before
editing. After editing, explain how I can run and check the test.
⚠️ Common Mistakes
- Accepting long suggestions without reading them
- Starting agent work with uncommitted changes
- Giving an agent access to real secrets
- Asking for many unrelated changes at once
- Trusting “all tests passed” without seeing the run yourself
🎯 Key Takeaways
- Assistants can suggest, explain or make multi-file changes.
- Project rules make their output more consistent.
- Small commits and diffs keep you in control.
- Agent access needs clear limits.
🎤 Interview Questions
1. How do you use AI coding assistants in test automation?
Model answer: I use them for drafts, explanations and small refactoring. I provide examples from the project, make one change at a time, read the diff and run the tests myself before committing.
2. How do you make an assistant follow team standards?
Model answer: I use a short project instruction file with locator rules, banned patterns and test conventions. I also point it to good existing tests, and I enforce important rules with linting and code review.
3. What are the risks of agent mode?
Model answer: It can edit several files, run commands or add unexpected changes. I reduce the risk with a separate branch, limited permissions, no real secrets and full review before merging.
4. What would you check in a diff produced by AI?
Model answer: I check scope, locators, assertions, waits, new dependencies and secrets. I look especially for changed expected results or removed checks that could hide a defect.
5. How do you protect sensitive data when using coding assistants?
Model answer: I use approved tools and settings, keep secrets outside the project and use synthetic data. I also check what files the tool can access, and I follow company policy.
📝 Assignment
Write a project instruction file with at least six rules. Ask your assistant for two new tests, one at a time. Record every rule it followed or broke. Update the file to fix one problem, and try again.
❓ FAQ
Which AI coding assistant should I choose?
Use one approved by your company. Good review habits matter more, and they transfer between tools.
Will an assistant make me a worse coder?
It can if you stop thinking. Read every change, ask why it works and write some code yourself.
🚀 Next Steps
Well done on finishing this lesson. Complete the assignment, then continue with Generate Playwright Tests with AI: Stable Locators and Real Assertions.