Testing
Tests are ordinary Faber source. There is no separate test language and no external runner to configure.
A single test#
proba declares one test. adfirma asserts.
faber format --locale en — English reader surfacetest "additio" {
assert 1 + 1 ≡ 2
}faber format --locale la — canonical Faberproba "additio" {
adfirma 1 + 1 ≡ 2
}faber format --locale th-TH — Thaiทดสอบ "additio" {
ยืนยัน 1 + 1 ≡ 2
}faber format --locale zh-Hans — Simplified Chinese测试 "additio" {
断言 1 + 1 ≡ 2
}faber format --locale zh-Hant — Traditional Chinese測試 "additio" {
斷言 1 + 1 ≡ 2
}faber format --locale vi — Vietnamesekiểm_thử "additio" {
khẳng_định 1 + 1 ≡ 2
}faber format --locale ar — Arabicاختبر "additio" {
أكد 1 + 1 ≡ 2
}faber format --locale hi — Hindiपरीक्षण "additio" {
पुष्टि 1 + 1 ≡ 2
}Grouping tests#
probandum groups related tests under one name.
faber format --locale en — English reader surfacetest "additio" {
assert 1 + 1 ≡ 2
}
test "multiplicatio" {
assert 2 * 3 ≡ 6
}faber format --locale la — canonical Faberproba "additio" {
adfirma 1 + 1 ≡ 2
}
proba "multiplicatio" {
adfirma 2 * 3 ≡ 6
}faber format --locale th-TH — Thaiทดสอบ "additio" {
ยืนยัน 1 + 1 ≡ 2
}
ทดสอบ "multiplicatio" {
ยืนยัน 2 * 3 ≡ 6
}faber format --locale zh-Hans — Simplified Chinese测试 "additio" {
断言 1 + 1 ≡ 2
}
测试 "multiplicatio" {
断言 2 * 3 ≡ 6
}faber format --locale zh-Hant — Traditional Chinese測試 "additio" {
斷言 1 + 1 ≡ 2
}
測試 "multiplicatio" {
斷言 2 * 3 ≡ 6
}faber format --locale vi — Vietnamesekiểm_thử "additio" {
khẳng_định 1 + 1 ≡ 2
}
kiểm_thử "multiplicatio" {
khẳng_định 2 * 3 ≡ 6
}faber format --locale ar — Arabicاختبر "additio" {
أكد 1 + 1 ≡ 2
}
اختبر "multiplicatio" {
أكد 2 * 3 ≡ 6
}faber format --locale hi — Hindiपरीक्षण "additio" {
पुष्टि 1 + 1 ≡ 2
}
परीक्षण "multiplicatio" {
पुष्टि 2 * 3 ≡ 6
}Tagging#
tag labels a test so it can be selected or filtered when running.
faber format --locale en — English reader surfacetest "concatenatio" tag "fast" {
assert "a" + "b" ≡ "ab"
}faber format --locale la — canonical Faberproba "concatenatio" tag "fast" {
adfirma "a" + "b" ≡ "ab"
}faber format --locale th-TH — Thaiทดสอบ "concatenatio" แท็ก "fast" {
ยืนยัน "a" + "b" ≡ "ab"
}faber format --locale zh-Hans — Simplified Chinese测试 "concatenatio" 标签 "fast" {
断言 "a" + "b" ≡ "ab"
}faber format --locale zh-Hant — Traditional Chinese測試 "concatenatio" 標籤 "fast" {
斷言 "a" + "b" ≡ "ab"
}faber format --locale vi — Vietnamesekiểm_thử "concatenatio" nhãn "fast" {
khẳng_định "a" + "b" ≡ "ab"
}faber format --locale ar — Arabicاختبر "concatenatio" وسم "fast" {
أكد "a" + "b" ≡ "ab"
}faber format --locale hi — Hindiपरीक्षण "concatenatio" टैग "fast" {
पुष्टि "a" + "b" ≡ "ab"
}Modifiers#
Modifiers follow the test name.
faber format --locale en — English reader surfacetest "stable" tag "fast" {
assert true
}
test "flaky guard" repeat 3 {
assert true
}
test "not written yet" todo "waiting on the parser" {
assert true
}faber format --locale la — canonical Faberproba "stable" tag "fast" {
adfirma verum
}
proba "flaky guard" repete 3 {
adfirma verum
}
proba "not written yet" futurum "waiting on the parser" {
adfirma verum
}faber format --locale th-TH — Thaiทดสอบ "stable" แท็ก "fast" {
ยืนยัน จริง
}
ทดสอบ "flaky guard" ทำซ้ำ 3 {
ยืนยัน จริง
}
ทดสอบ "not written yet" ค้าง "waiting on the parser" {
ยืนยัน จริง
}faber format --locale zh-Hans — Simplified Chinese测试 "stable" 标签 "fast" {
断言 真
}
测试 "flaky guard" 重复 3 {
断言 真
}
测试 "not written yet" 预期 "waiting on the parser" {
断言 真
}faber format --locale zh-Hant — Traditional Chinese測試 "stable" 標籤 "fast" {
斷言 真
}
測試 "flaky guard" 重複 3 {
斷言 真
}
測試 "not written yet" 預期 "waiting on the parser" {
斷言 真
}faber format --locale vi — Vietnamesekiểm_thử "stable" nhãn "fast" {
khẳng_định đúng
}
kiểm_thử "flaky guard" lặp_lại 3 {
khẳng_định đúng
}
kiểm_thử "not written yet" việc_cần_làm "waiting on the parser" {
khẳng_định đúng
}faber format --locale ar — Arabicاختبر "stable" وسم "fast" {
أكد صواب
}
اختبر "flaky guard" معاد 3 {
أكد صواب
}
اختبر "not written yet" مستقبلي "waiting on the parser" {
أكد صواب
}faber format --locale hi — Hindiपरीक्षण "stable" टैग "fast" {
पुष्टि सत्य
}
परीक्षण "flaky guard" पुनरावृत्ति 3 {
पुष्टि सत्य
}
परीक्षण "not written yet" लंबित "waiting on the parser" {
पुष्टि सत्य
}| Modifier | Meaning |
|---|---|
tag "<name>" | Label for selection and filtering |
repete <n> | Run the test n times — catches flakiness |
futurum "<reason>" | Expected-pending; documents why it does not run yet |
omitte | Skip |
repete is a test modifier, not a loop. For loops see
Loops.
Asserting#
adfirma takes any boolean expression.
faber format --locale en — English reader surfacetest "comparisons" {
assert 1 + 1 ≡ 2
assert 3 ≻ 2
assert "abc".longitudo() ≡ 3
}faber format --locale la — canonical Faberproba "comparisons" {
adfirma 1 + 1 ≡ 2
adfirma 3 ≻ 2
adfirma "abc".longitudo() ≡ 3
}faber format --locale th-TH — Thaiทดสอบ "comparisons" {
ยืนยัน 1 + 1 ≡ 2
ยืนยัน 3 ≻ 2
ยืนยัน "abc".longitudo() ≡ 3
}faber format --locale zh-Hans — Simplified Chinese测试 "comparisons" {
断言 1 + 1 ≡ 2
断言 3 ≻ 2
断言 "abc".longitudo() ≡ 3
}faber format --locale zh-Hant — Traditional Chinese測試 "comparisons" {
斷言 1 + 1 ≡ 2
斷言 3 ≻ 2
斷言 "abc".longitudo() ≡ 3
}faber format --locale vi — Vietnamesekiểm_thử "comparisons" {
khẳng_định 1 + 1 ≡ 2
khẳng_định 3 ≻ 2
khẳng_định "abc".longitudo() ≡ 3
}faber format --locale ar — Arabicاختبر "comparisons" {
أكد 1 + 1 ≡ 2
أكد 3 ≻ 2
أكد "abc".longitudo() ≡ 3
}faber format --locale hi — Hindiपरीक्षण "comparisons" {
पुष्टि 1 + 1 ≡ 2
पुष्टि 3 ≻ 2
पुष्टि "abc".longitudo() ≡ 3
}Where tests live, and running them#
Tests sit beside the code they exercise, inside the package. Run them with:
faber test <package>Related: Commands · Errors and testing