E81007: @Test program has no assertions and no expected output files
What went wrong
A @Test program has neither assertions nor expected output files. The test validates nothing - it would always pass (false confidence).
Worked examples
Compilable examples demonstrating this error and the correct fix:
- ek9 -q 809 (How does EK9 enforce test quality at compile time?)
- ek9 -q 804 (Why does EK9 have a built-in test framework instead of us...)
- ek9 -q 806 (How do I group tests and control execution order in EK9?)
[EK9 TESTING APPROACHES]
- Assert-based: use assert/assertThrows in code (unit tests)
- Black-box: expected_output.txt or expected_case_*.txt (regression)
- Hybrid: both assertions and expected output files
How to fix it
- Add assertions: `assert result == 4`
- Or add expected_output.txt with expected stdout
- Or remove @Test if it's not actually a test
Rationale
Tests that validate nothing mask real bugs. EK9 catches this at compile time - other languages only discover it when bugs slip through.
Examples
Every example is compiled by the EK9 compiler: the first fails exactly as captioned, the others fix it.
Fails with E81007: @Test program has no assertions and no expected output files - reported by the test runner, not the compiler, when ek9 -t greeting.ek9 runs in this project.
bad/greeting.ek9
#!ek9 defines module error.e81007.bad defines function greeting() as pure -> name as String <- result as String: `Hello, ${name}`
bad/dev/tests.ek9
#!ek9 defines module error.e81007.bad.tests references error.e81007.bad::greeting defines program @Test GreetingOnce() stdout <- Stdout() stdout.println(greeting("EK9"))
$ ek9 -t greeting.ek9
ek9: compilation failed (exit 8)
EK9 : PRE_IR_CHECKS: Errors in ./dev/tests.ek9
EK9 : Error : E81007: 'GreetingOnce' on line 10 position 4: 'error.e81007.bad.tests::GreetingOnce' has no assertions and no expected output files: @Test program has no assertions and no expected output files
See: ek9 -h E81007
EK9 : Compilation failed
Fixed: expected_output.txt says what the test must print
good/greeting.ek9
#!ek9 defines module error.e81007.good defines function greeting() as pure -> name as String <- result as String: `Hello, ${name}`
good/dev/tests.ek9
#!ek9 defines module error.e81007.good.tests references error.e81007.good::greeting defines program @Test GreetingOnce() stdout <- Stdout() stdout.println(greeting("EK9"))
good/dev/expected_output.txt
Hello, EK9
$ ek9 -t greeting.ek9
ℹ️ Found 1 test:
1 blackbox (output validated against expected_output.txt)
Executing 1 test...
✅ PASS error.e81007.good.tests::GreetingOnce [BlackBox] (nms)
Summary: 1 passed, 0 failed (1 total)
Types: 1 blackbox
Duration: nms
Questions and answers
These Q&A entries show E81007 and its fix: