liveBook · Manning

Test

As explained in Julia as a Second Language

Software testing is the systematic evaluation of software behavior using prescribed inputs and expected results to detect defects and verify correctness.

Testing checks whether software still behaves as expected after changes. REPL checks are useful during development, but larger projects need repeatable tests that expose regressions across many files. section 16.5

A Julia package test suite lives in test/runtests.jl and runs separately from the module under test. The test environment imports both the package and Julia's Test package. section 16.5

A practical package-testing setup uses:

  • A test directory containing runtests.jl and focused files such as trigtests.jl. section 16.5
  • Nested @testset blocks, where an enclosing set succeeds only when its contained sets succeed. section 16.5

Catching and fixing a cosine regression

ToyGeometry tests compare cosine(π) and cosine(0) with expected values, then compare cosine against cos across 0:0.1:2π. An initial run reports 108 passes and 22 failures. Increasing the cosine approximation's series limit from 5 to 9 makes all 130 tests pass.

How Julia as a Second Language covers it

How deep it goes
Covers basic setup, nested test sets, assertions, environments, execution, and one fix, while deferring broader testing practice.
Examples
Uses ToyGeometry trigonometric tests, sampled cosine and sine comparisons, failure summaries, and a corrected cosine approximation.
What it assumes
Assumes a Julia package and module exist, while teaching test-file organization, Test imports, and test-specific environments.
What you can do after
Operate Julia package tests through the package manager and diagnose failures using test summaries.
How it connects
Connects testing with packages, modules, environments, dependencies, and the Julia package manager.

Also explained in

Compare how 53 books explain test →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Julia as a Second Language. The section links point to the parts of the book it draws on.