Program StructureTesting
Blorp by Example

Testing

Blorp tests are ordinary functions collected in a TestSuite.

Testsuite

A TestSuite has a description and a list of named test functions.

suite.brp
tests: TestSuite = {
    description = "scores",
    tests = [("passing", test_passing)],
}

Assertions

Tests can return Bool directly or use helpers from test.

assertion.brp
func test_passing() -> Bool:
    classify(82) == "passing"

Running Tests

Run one file with blorp test path/to/test.brp.

terminal
blorp test test_scores.brp

Organizing Examples

Keep test files near the behavior they describe and name tests for outcomes.

test-name.brp
("empty input returns None", test_empty_input)

Example

test_scores.brp
import:
	test: TestSuite


pure func classify(score: Int) -> String:
	if score >= 70:
		"passing"
	else:
		"needs practice"


func test_passing_score() -> Bool:
	classify(82) == "passing"


func test_low_score() -> Bool:
	classify(61) == "needs practice"


tests: TestSuite = {
	description = "score classification",
	tests = [("passing score", test_passing_score), ("low score", test_low_score)],
}

Try It

terminal
blorp test test_scores.brp