Skip to main content

baml-cli test

Run tests defined in your BAML files with filtering, parallel execution, and various output formats.

Usage​

baml-cli test [OPTIONS]

Options​

OptionDescriptionDefault
--from <PATH>Path to baml_src directory./baml_src
--listList tests without runningfalse
-i, --include <PATTERN>Include specific testsRun all
-x, --exclude <PATTERN>Exclude specific testsNone
--parallel <NUM>Parallel test count10
--pass-if-no-testsPass if no tests selectedfalse
--require-human-evalFail if tests need human evaltrue
--dotenvLoad .env filetrue
--dotenv-path <PATH>Custom .env file pathNone

Pattern Syntax​

  • * - matches any characters
  • FunctionName::TestName - specific test
  • FunctionName:: - all tests in function
  • ::TestName - test name across functions

Examples​

Basic Testing​

# Run all tests
baml-cli test

# List available tests
baml-cli test --list

# Run from specific directory
baml-cli test --from /path/to/baml_src

Test Filtering​

# Run tests for specific function
baml-cli test -i "ExtractResume::"

# Run specific test
baml-cli test -i "ExtractResume::TestBasicResume"

# Run tests matching pattern
baml-cli test -i "Extract*::"

# Multiple include patterns
baml-cli test -i "Extract*::" -i "Classify*::"

# Exclude specific tests
baml-cli test -x "ExtractResume::TestComplexResume"

# Combine include and exclude
baml-cli test -i "Extract*::" -x "*::TestSlow*"

Parallel Execution​

# Default parallelism (10)
baml-cli test

# Sequential execution
baml-cli test --parallel 1

# High parallelism
baml-cli test --parallel 20

Environment Variables​

# Use default .env loading
baml-cli test

# Disable .env loading
baml-cli test --no-dotenv

# Custom .env file
baml-cli test --dotenv-path .env.test

# Set directly
OPENAI_API_KEY=... baml-cli test

Exit Codes​

CodeMeaning
0All tests passed
1Test failures occurred
2Tests require human evaluation
3Execution cancelled
4No tests found

See Also​