Skip to content

Tested Project

You'll put a real test suite under a project, with tests that run on every push, so you'd notice within a minute if you broke something.

About

One test is a habit, and a suite is infrastructure. This badge takes a project with real behavior and puts a net under it: unit tests, a few integration tests, coverage you can read, and a machine that runs it all every time you push. The first CI run will fail on something you installed by hand a year ago and forgot about. After this you'll feel a bit exposed working on code without it.

At a glance

Per requirement
35 XP
Completion bonus
300 XP
Requirements
6
Takes
A month
Skill level
Intermediate (months of practice)
Cost
Free
Supplies
Nothing special
Where
At home
Other people
On your own
Locked for now
Earn two more Uncommon badges in Coding to open this one. Log in to see how far along you are.

Requirements

  1. 1
    Pick a project of at least 300 lines with no tests, and write ten unit tests for its purest functions. Start with the functions that take input and return output without touching files or the network. Those are the easy ones, and they find bugs anyway. Take a screenshot of the ten tests passing. Photo
  2. 2
    Write three integration tests that run the program end to end. Feed in a real input file and check the real output. Use a temporary directory so the tests don't leave junk behind. These are slow, and they catch the bugs unit tests can't. Take a screenshot of them passing with their runtime. Photo
  3. 3
    Measure coverage and get the core logic above 80 percent. Use coverage.py, Jest with --coverage, or go test -cover. Don't chase 100 percent, and test the parts that would hurt if they broke. Take a screenshot of the coverage report. Photo
  4. 4
    Set up continuous integration so the suite runs on every push. GitHub Actions and GitLab CI both have a free tier. You need a YAML file that installs the dependencies and runs the tests. Push a commit and watch it go green. Take a screenshot of the green check on the commit. Photo
  5. 5
    Push a commit that breaks a test and watch CI go red, then fix it. You need to see what failure looks like before you can trust the green. Take a screenshot of the red run, then of the green one after the fix. Photo
  6. 6
    Write a test for a bug before fixing the bug, three times over. Each time a bug shows up over the next month, reproduce it in a test first. Go red, fix it, and go green. You want three commits with that shape. Take a screenshot of the three commits in git log with the test files in the diff. Photo