Early preview: syntax, standard library APIs, and tooling may change.

Program StructureTesting

Testing

Blorp tests are ordinary functions collected in a TestSuite.

TestSuite

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

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

Assertions

Tests can return Bool directly or use helpers from test.

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.

("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