Reading & Writing Test Scripts
Part of the QA Testing Roadmap
In short
On day one at a job, you'll read far more test code than you write. A clean test is one a new teammate can understand in thirty seconds.
Applying everything from this phase together — writing clean, readable test scripts and being able to understand and modify scripts written by someone else, a daily skill in any automation role.

Think of it like this
The college lab journal
Every physics practical follows the same format: aim, apparatus, procedure, observation, result. Any student can open your journal and follow it. Good test scripts have a fixed shape too: set up, do the action, check the result.
Watch it happen
Arrange, Act, Assert
1/4Set the scene: create test data, open the page, log in if needed.
The big ideas
What you need to know
Names explain intent
test_coupon_reduces_total_by_10_percent beats test1. The name is the first documentation.
One behaviour per test
A test that checks ten things fails for ten reasons. Keep each test focused.
Read before you edit
Run an existing test first, then trace it top to bottom before changing anything.
Comments say why
The code shows what. Comments explain the business rule or the odd workaround.
See it in code
Walk through the code
1def apply_coupon(total, code):2 return total * 0.9 if code == "SAVE10" else total3 4 5def test_save10_coupon_takes_10_percent_off():6 # Arrange7 cart_total = 5008 9 # Act10 new_total = apply_coupon(cart_total, "SAVE10")11 12 # Assert13 assert new_total == 4501/4The code under test. In real work this would be your app or a page action.
A pytest test in Arrange, Act, Assert shape. Run it with pytest -q after pip install pytest.
Save yourself the pain
Common mistakes
Oops
Copying a teammate's test and changing values without understanding it.
Do this instead
Run it, read it line by line, and explain it out loud before editing.
Oops
Hiding magic numbers like 0.9 with no explanation.
Do this instead
Use a named value or comment: SAVE10 gives 10% off.
Your mission
Rewrite a messy test
Quick check
In Arrange, Act, Assert, where does 'click the Apply Coupon button' belong?
Go deeper
- 1Read an open-source test automation script and explain what it does, line by line.
- 2Practice modifying an existing script to add a new test case.
- 3Learn to write scripts with clear naming, since automation code is read far more often than written.
More topics at this stop
Stuck on this topic? Ask an Insider
Get 1:1 guidance from people who've walked this exact path — on the InsideEdge app.