Test Cases for Every Branch of Your Code

Every diamond in a flowchart has two ways out, and each needs a test that takes it. Paste your program to see, on its flowchart, which branches your sample input really ran (green) and which it never reached (red). Then get an input for each one, including the edge cases a teacher or interviewer would try.

  • Branch coverage on the flowchart: tested in green, never tested in red
  • Free coverage from your own dry runs, no AI needed
  • AI-suggested inputs for every untested if, else and loop exit, with the expected output
  • Edge cases like 0, negative numbers and equal values
  • Each suggestion is checked with a real dry run before it counts
  • Branches that can never run (dead code) are pointed out

How it works

  1. Paste your program and a sample input
  2. See which branches that input tested
  3. Press ✦ Find test inputs for the rest
  4. Dry run each input until every branch is green

Try it with

  • int n, i, sum = 0; scanf("%d", &n); for (i = 1; i <= n; i++) sum = sum + i; printf("Sum = %d", sum);
  • n = int(input()) fact = 1 for i in range(1, n + 1): fact = fact * i print(fact)
  • int a, b, c; scanf("%d %d %d", &a, &b, &c); if (a >= b && a >= c) printf("%d", a); else if (b >= c) printf("%d", b); else printf("%d", c);

Frequently asked questions

Is the test case generator free?

Seeing which branches your dry runs tested is free. Asking the AI for test inputs uses one AI credit, and each extra dry run uses one; free accounts get AI credits every month.

Does it run my code?

No. Like the rest of the code tool, the AI works out the dry run step by step, so nothing is executed. That is why a suggested input only counts as tested after its dry run takes the branch it promised.

What is branch coverage?

The share of branches (both ways out of every if, and both continue and exit of every loop) that at least one test takes. A program can print the right answer for your sample input and still be wrong on a branch the sample never reached.

Which languages are supported?

C, C++, Java, Python and JavaScript, for programs up to about 300 lines. Long dry runs stop after about 45 steps, so use small inputs (a few numbers, not a hundred).

Classic programs with flowchart, algorithm and code

Related tools

Try AI Flowchart free →