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