API Reference

NarrativeTest.runtestsFunction
runtests(files; subs = common_subs(), mod = nothing, quiet = false, exitfirst = false, maxfail = nothing) :: Bool

Load the specified Markdown files to extract and run the embedded test cases. When a directory is passed, load all *.md files in the directory. This function returns true if the testing is successful, false otherwise.

Specify subs to customize substitutions applied to the expected output in order to convert it to a regular expression.

Specify mod to execute tests in the context of the given module.

Set quiet = true to suppress all output except for error reports.

Set exitfirst = true to exit on first error or failure. Alternatively, use maxfail to set maximum allowable number of errors or failures.

runtests(; default = common_args(), subs = common_subs(), mod = nothing, quiet = false, exitfirst = false, maxfail = nothing)

In this form, test files are specified as command-line parameters. When invoked without parameters, tests are loaded from *.md files in the program directory, which can be overriden using default parameter. This function terminates the program with code 0 if the testing is successful, 1 otherwise.

Use this form in test/runtests.jl:

using NarrativeTest
NarrativeTest.runtests()
source
NarrativeTest.testsetFunction
testset(files = nothing;
        default = common_args(), subs = common_subs(), mod = nothing, quiet = false, exitfirst = false, maxfail = nothing)

Run NarrativeTest-based tests as a nested test set. For example, invoke it in test/runtests.jl:

using Test, NarrativeTest

@testset "MyPackage" begin
    …
    NarrativeTest.testset()
    …
end

The given Markdown files are analyized to extract and run the embedded test cases. When a directory is passed, all nested *.md files are loaded. When invoked without arguments, all *.md files in the program directory are loaded, which can be overridden using the default parameter.

Specify subs to customize substitutions applied to the expected output in order to convert it to a regular expression.

Specify mod to execute tests in the context of the given module.

Set quiet = true to suppress all output except for error reports.

source
NarrativeTest.runtestFunction
runtest(test::TestCase; subs = common_subs(), mod = nothing) :: AbstractResult
runtest(loc, code; pre = nothing, expect = nothing, subs = common_subs(), mod = nothing) :: AbstractResult

Run the given test case, return the result.

source
NarrativeTest.parsemdFunction
parsemd(file) :: Vector{AbstractTestCase}
parsemd(name, io) :: Vector{AbstractTestCase}

Parse the specified Markdown file to extract the embedded test suite; return a list of test cases.

source
NarrativeTest.parsejlFunction
parsejl(file) :: Vector{AbstractTestCase}
parsejl(name, io) :: Vector{AbstractTestCase}

Load the specified Julia source file and extract the embedded test suite; return a list of test cases.

source
NarrativeTest.common_subsFunction
common_subs() :: Vector{Pair{Regex,SubstitutionString{String}}}

Substitutions applied to the expected output in order to convert it to a regular expression.

source