Skip to content

Building with AI

How to prove your app works: testing for beginners

What software testing is, how to test an app by hand, how to write your first automatic checks in JavaScript, and why tests matter more when AI writes code.

By the GenKid team · · Updated · Facts checked · 4 min read

Key takeaways

  • Testing means checking that your app does what it should — and doesn't do what it shouldn't.
  • Start with manual tests: the normal path, then edge cases like empty, zero, huge or repeated inputs.
  • Automatic checks are small pieces of code that test your code, so you can re-run them after every change.
  • Tests are especially important with AI, because AI changes can quietly break things that used to work.
  • Never change a test just to make it pass; a failing test is information.

What testing is

Testing is how you find out whether your app really works. It sounds obvious, but most bugs survive because nobody tried the thing that breaks them.

England's computing curriculum asks pupils from primary school to design, write and debug programs, and to use logical reasoning to detect and correct errors. Testing is how you find those errors before someone else does.

Start with manual testing

Manual testing means using the app yourself, deliberately. Do it in two passes.

Pass 1: the happy path

Use each feature the normal way. Click the buttons, fill in the boxes, play the game. Does everything do what it should?

Pass 2: try to break it

Now be mischievous. Try:

  • Empty — submit nothing.
  • Zero and negative — 0, -1.
  • Huge — a very long name, a very big number.
  • Weird — spaces only, emoji, symbols.
  • Repeated — click the button ten times fast.
  • Boundaries — the last question, the maximum score, exactly the limit.

Write down anything that goes wrong, with the steps to make it happen. That's a bug report, and it's the start of debugging.

Write your first automatic checks

Manual testing is great, but slow to repeat. Automatic checks are small bits of code that test your code. Here's a tiny check helper in JavaScript:

function check(label, actual, expected) {
  if (actual === expected) {
    console.log("PASS " + label);
  } else {
    console.log("FAIL " + label + ": got " + actual + ", expected " + expected);
  }
}

Now test a function from a dragon egg game, where an egg hatches when its warmth reaches 5:

function isHatched(egg) {
  return egg.warmth >= 5;
}

check("warmth 5 hatches", isHatched({ warmth: 5 }), true);
check("warmth 4 does not hatch", isHatched({ warmth: 4 }), false);
check("warmth 0 does not hatch", isHatched({ warmth: 0 }), false);

Run the app and read the console. In most desktop browsers you open it with F12 or Ctrl + Shift + I (Cmd + Option + I on a Mac), then choose the Console tab. In GenKid's workspace, console.log messages appear in the console panel next to your app. (Not sure what the console is for? See HTML, CSS and JavaScript explained.)

Every time you (or an AI) change the code, run the checks again. If something that used to pass now fails, you've caught a bug immediately.

Professional developers do the same thing with testing frameworks, which add helpful features but work on the same idea.

Why testing matters more with AI

When an AI changes your code, it can fix one thing and break another without telling you. It may also be confident its change works when it doesn't. Tests give you an independent answer.

A few rules for testing with AI:

  • Write or agree the tests before the AI builds the feature. Tests describe what "works" means.
  • Run them after every AI change. See how to check code an AI wrote.
  • Never let the AI "fix" a failing test by changing the test, unless you agree the test itself was wrong. A failing test is telling you something. Watch for this especially with AI coding agents, which can edit many files, tests included, in one go.
  • Ask the AI to suggest edge cases, but decide yourself which ones matter.

What to test first

You can't test everything, so test what matters most:

PriorityExamples
Rules of the appScoring, winning, prices, limits
Anything with user inputNames, answers, forms
Things that broke beforeEvery bug you fixed deserves a test
BoundariesFirst, last, empty, maximum

Testing is a mindset

A habit that helps: before you run your checks, predict which ones will pass. It's the same "predict, then run" step behind reading code before writing it, and it trains you to notice when something surprises you.

Testers ask "how could this go wrong?" That mindset is valuable everywhere: checking an essay, planning a trip or judging whether an AI's answer is true. It's part of thinking critically, not just coding.

GenKid includes testing from Level 2: learners write checks that define what "works" means, then use them to find bugs in AI-written code — including a final bug the checks themselves uncover. See the pathway.

Frequently asked questions

What is a unit test?

A unit test is a small automatic check that tests one small piece of code, such as one function, with known inputs and expected outputs.

How many tests should I write?

Enough to cover the main rules of your app, the edge cases and every bug you've fixed. For a small app, a handful of well-chosen checks is a great start.

What's an edge case?

An unusual input or situation at the limits of what your app expects, such as an empty name, zero, a huge number or the last item in a list. Bugs often hide there.

Can AI write my tests?

AI can suggest tests, but you should decide what "correct" means and check the tests are right. If the AI writes both the code and the tests, they can share the same mistake.

Sources

  1. National curriculum in England: computing programmes of study (opens in a new tab) — Department for Education
  2. What are browser developer tools? (opens in a new tab) — MDN Web Docs

How we write: GenKid articles are researched and drafted with the help of AI tools, then checked in a separate review step against the sources listed above before they are published, and re-checked when they are updated. Rules and products change, so check official pages for your country before acting on anything here. This article is general information, not legal advice. Spotted a mistake? Email hello@genkid.app.