Java basics for testers: read and write a small test
Many automation tools use Java. Learn variables, methods, classes and conditions well enough to read a test and change it with care.
L1–L4 are part of the Pro pass
L0 Explain simply
Analogy: a recipe card. A recipe card has a name, a list of ingredients and steps. Some steps say if the dough is dry, add water. Some say stir ten times.
A cook who can read the card can follow it or change it with care.
Java code is like a recipe card. Tom, the tester at Daily List, a to-do list app, needs to read these cards, because many test tools are written in Java.
PICTURE IT
The picture is the one the lesson above opens with. The table below shows how each part of it matches the software.
THE REAL JOB Reading and changing small Java tests, like following a recipe card.
- Class
- Method
- Variable
- If
HOW THE PICTURE MAPS
| In the picture | In the software |
|---|---|
| The recipe card | The class |
| One recipe | A method |
| An ingredient | A variable |
| If dry, add water | An if statement |
WHERE THIS PICTURE STOPS
- A recipe is for one cook, but code runs by itself.
- A cook can guess, but the compiler cannot.
- A recipe has a few steps, but a class may have many.
HOOK
Class, method, variable, if.
TELL A FRIEND
A recipe card: a name, ingredients, steps and ifs.
OFTEN MIXED UP WITH Programming basics for testers (read, don't build). That topic teaches programming ideas in any language. This one puts the same ideas into Java.
PRACTISE AND KEEP
Sources for this topic — 2 sources
- Market practice
Language Basics (The Java Tutorials, Oracle) ↗ — Oracle · Oracle Java Tutorials: the eight primitive data types are byte, short, int, long, float, double, boolean and char, and control flow includes if-then, switch, for and while (search excerpt, page not opened)
Found through a web search; the page was not opened (search excerpt, page not opened). Version: Web page, no edition number. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.
- Market practice
JUnit 5 user guide (JUnit documentation) ↗ — JUnit team · JUnit 5 user guide: tests are methods marked with annotations and run by the JUnit platform (search excerpt, page not opened)
Found through a web search; the page was not opened (search excerpt, page not opened). Version: Web page for the 5.14.0 guide as listed in a search; read as a search excerpt only. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.
Deepest material on this page: L4 — Standards & sources. Where a topic stops short of implementation depth, that is a deliberate coverage decision, not an oversight — see coverage.