Renderingen-US

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.

reader locale
faber format --locale en — English reader surface
test "additio" {
    assert 1 + 1  2
}
faber format --locale la — canonical Faber
proba "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 — Vietnamese
kiể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.

reader locale
faber format --locale en — English reader surface
test "additio" {
    assert 1 + 1  2
}

test "multiplicatio" {
    assert 2 * 3  6
}
faber format --locale la — canonical Faber
proba "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 — Vietnamese
kiể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.

reader locale
faber format --locale en — English reader surface
test "concatenatio" tag "fast" {
    assert "a" + "b"  "ab"
}
faber format --locale la — canonical Faber
proba "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 — Vietnamese
kiể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.

reader locale
faber format --locale en — English reader surface
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 format --locale la — canonical Faber
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 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 — Vietnamese
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 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" {
    पुष्टि सत्य
}
ModifierMeaning
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
omitteSkip

repete is a test modifier, not a loop. For loops see Loops.

Asserting#

adfirma takes any boolean expression.

reader locale
faber format --locale en — English reader surface
test "comparisons" {
    assert 1 + 1  2
    assert 32
    assert "abc".longitudo()  3
}
faber format --locale la — canonical Faber
proba "comparisons" {
    adfirma 1 + 1  2
    adfirma 32
    adfirma "abc".longitudo()  3
}
faber format --locale th-TH — Thai
ทดสอบ "comparisons" {
    ยืนยัน 1 + 1  2
    ยืนยัน 32
    ยืนยัน "abc".longitudo()  3
}
faber format --locale zh-Hans — Simplified Chinese
测试 "comparisons" {
    断言 1 + 1  2
    断言 32
    断言 "abc".longitudo()  3
}
faber format --locale zh-Hant — Traditional Chinese
測試 "comparisons" {
    斷言 1 + 1  2
    斷言 32
    斷言 "abc".longitudo()  3
}
faber format --locale vi — Vietnamese
kiểm_thử "comparisons" {
    khẳng_định 1 + 1  2
    khẳng_định 32
    khẳng_định "abc".longitudo()  3
}
faber format --locale ar — Arabic
اختبر "comparisons" {
    أكد 1 + 1  2
    أكد 32
    أكد "abc".longitudo()  3
}
faber format --locale hi — Hindi
परीक्षण "comparisons" {
    पुष्टि 1 + 1  2
    पुष्टि 32
    पुष्टि "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