---
title: "19.7 Testing it"
url: https://una-lang.org/en/learn/editions/testing-it/
release: v0.4.0
edition: "0.1, 0.2, 0.3, 0.4"
---

# 19.7 Testing it

## 19.7.1 Three tests on the export of `main`

The package is of edition `0.3`, so each one is a `test`. The tests check the parser and both kinds of run, on the same export that `main` uses, so a reader can compare their numbers with the program's output. The two runs use `silent`, so they print nothing, and they check what was performed:

```una include="day-to-day/src/labels.una#L72-L86" title="day-to-day/src/labels.una" caption="the examples"
test "a line that does not parse is left out"
  do read_lines(export()).len
  expect result == 3

test "a dry run counts the labels and prints none"
  given @printer = silent()
  do print_labels(read_lines(export()), dry_run: true)
  expect result == 2
  expect not performed @printer.print_label

test "a run prints a label for each line with stock"
  given @printer = silent()
  do print_labels(read_lines(export()), dry_run: false)
  expect result == 2
  expect performed @printer.print_label
```

## 19.7.2 A plain `dry_run` and the calls `silent` records

The tests pass `dry_run` as a plain `true` or `false`. Here the tests have nothing to prove about it: each installs its own printer with `given`, and the condition is proven once, inside `print_labels`, for every value of `dry_run`, so the tests only check behavior. `silent` answers every `print_label` with `unit`, and the trace of each test records the calls, which `expect performed` and `expect not performed` read.

## 19.7.3 The proof and the tests

The proof and the tests cover different ground. The verifier proves, for every list and every call, that a label is printed only when `dry_run` is false, and the lock in `una.toml` keeps that rule from being dropped. The test "a dry run counts the labels and prints none" checks the same rule on one list, with `expect not performed`, and also checks the count, which no condition states. After an upgrade of `una` to a later release, rerun both: a stricter rule can only add obligations or errors, and the tests catch a change in behavior.

## 19.7.4 Running the tests

`una test .` prints:

```text include="day-to-day/expected/commands/test.txt#L2-L6"
test labels "a line that does not parse is left out" ... ok
test labels "a dry run counts the labels and prints none" ... ok
test labels "a run prints a label for each line with stock" ... ok

3 tests: 3 passed, 0 failed
```
