4.2 just cov

Build it yourself. Read the tutorial is the other way to read this part.

This walk goes through rahuldave/cheesecracker on GitHub. This part starts from the code at 54de20e8055e, partway through step-04. The code before this part

This part does not start where the part before it ends, because the walk skips some changes. This command puts the files that this part starts from in place of yours. Run it, and then go on:

git fetch --quiet --tags --force origin; git restore --source step-02 --staged -- :/ && git restore --source 54de20e8055e --staged --worktree -- :/

If you start at this part, make your clone as Get the project says, and then run this command. It puts in your clone the files that this part starts from. A file that the project deleted before this part stays, so delete it if git check lists it:

git rm -rq --cached --ignore-unmatch -- :/ && git restore --source 54de20e8055e --staged --worktree -- :/
just setup

The whole tutorial then adds an endpoint, ten integration tests, and pytest-cov, which measures the lines that the tests run. Coverage gets a recipe.

4.2 just cov shows which lines the tests run

The recipe cov runs every test with coverage, and adds the column Missing, with the numbers of the lines that no test ran.

Apply the patch to justfile, from the top of the project:

curl -fsSL https://github.com/rahuldave/cheesecracker/commit/bfb9c783c67c31254ce8136784738c0f2fc17fb5.diff | git apply --include=justfile

Read the recipe cov at the end of the justfile.

just cov -q

The total is 95%. service.py misses line 31, the answer of /health, because no test asks for it.

Check your files against this move. The command prints nothing when they match, and otherwise shows what differs:

git check bfb9c783c67c

If you are stuck, this command puts the files of this move in place of yours. A file that you made yourself stays:

git fetch --quiet --tags --force origin; git restore --source 54de20e8055e --staged -- :/ && git restore --source step-04 --staged --worktree -- :/

What changed

  • justfile: the recipe cov. 4 lines added. The file
    • look at uv run pytest --cov=api --cov-report=term-missing "$@"

The patch to justfile
@@ -40,3 +40,7 @@ stop:
     done
     echo "stop: the server still answers after 30 seconds" >&2
     exit 1
+
+# Run the tests, and show which lines of the package api they ran. Extra arguments go to pytest: just cov tests/unit
+cov *args:
+    uv run pytest --cov=api --cov-report=term-missing "$@"

This change on GitHub

This part ends at the code at step-04. The code after this part