unit test

An automated check of one small piece of code, such as a single function, that runs quickly and on its own.

In more detail

Each test calls the code with known inputs and asserts the expected result, so a later change that breaks it is caught immediately. Good unit tests cover ordinary cases, edge cases such as empty input, and error cases.

Examples

Component unit tests render a component and assert on its DOM, roles and behaviour, but cannot see layout or pixel problems.
Go: func TestHealthy(t *testing.T) in a _test.go file, run by go test
def test_word_count():
    assert word_count("a b c") == 3

Related terms

Taught in

References

Certification courses