Skip to content

Test Attributes

The @test and @suite decorators accept attributes that refine runner behaviour without changing the code under test.

skip

skip: "reason" marks the test to be ignored, but still displays it in the report as pending. Ideal for cases not yet implemented:

Runs via zolo test. Illustrates skip (skipped test), should_throw (expected failure), and a normal @test in the same file.

03-attrs.zolo
@test(skip: "ainda nao implementado")
fn pulado() { expect(1).to_eq(2) }   // would fail, but skipped


@test(should_throw: "out of range")
fn deve_lancar() {
  panic("out of range")
}

@test
fn normal() { expect(1).to_eq(1) }

Requires the Zolo CLI/host — open in the playground or run locally.

should_throw

should_throw: "message" inverts the expectation: the test passes if — and only if — the body panics with the given message. Use it to validate contract behaviour.

only

When at least one @test(only) exists in the file, the runner ignores all other tests. Useful for focusing on a single case during development:

focus is the only test that runs; ignored_by_only would fail, but is automatically skipped by the presence of only.

05-only.zolo
@test(only)
fn foco() { expect(1).to_eq(1) }

@test
fn ignorado_por_only() { expect(1).to_eq(2) }  // would fail, but skipped due to `only`

Requires the Zolo CLI/host — open in the playground or run locally.

tag

tag: associates labels with the test, enabling filtering on the command line (zolo test --tag fast). Accepts a string or a list of strings:

fast has the tag "fast"; slow has two tags ["slow", "network"].

04-tags.zolo
@test(tag: "fast")
fn rapido() { expect(1).to_eq(1) }

@test(tag: ["slow", "network"])
fn lento() { expect(1).to_eq(1) }

Requires the Zolo CLI/host — open in the playground or run locally.

Challenge

Create a test with skip: "TODO" and another with should_throw: "division by zero". Run zolo test and check how each one appears in the report.

enespt-br