← Back to the index

9. Testing Framework

In this chapter

Test Blocks

vv has an integrated testing framework. Tests are defined using the test keyword followed by a string description and closed with end.

test "Addition works correctly"
    let result = 2 + 2
    assert result == 4
end

These blocks are not executed during normal program execution. They are only run when invoked by a test runner.

Assertions

The assert keyword takes a boolean expression. If the expression evaluates to false, the test fails.

assert 1 < 2 // Test passes
assert 2 == 3 // Test fails with an assertion error