API
Installer/Uninstaller Functions
TestTools.TestTools — ModuleThe TestTools package provides support for testing and code quality CLIs.
TestTools.install — FunctionTestTools.install(; kwargs...)Install all of the CLI utilities.
Keyword arguments
julia::AbstractString: path to julia executable. Default: path of the current running juliabin_dir::AbstractString: directory to install CLI utilities into. Default:~/.julia/binforce::Bool: flag used to indicate that existing CLI executables should be overwritten. Default:false
TestTools.uninstall — FunctionTestTools.uninstall(; kwargs...)Unnstall all of the CLI utilities.
Keyword arguments
bin_dir::AbstractString: directory containing CLI executables to uninstall. Default:~/.julia/bin
jltest
TestTools.jltest — ModuleThe jltest module provides support for running unit tests.
TestTools.jltest.find_tests — Functionfind_tests(dir::AbstractString), kwargs...) -> Vector{String}Construct a list of absolute paths to Julia test files contained in dir.
Keyword Arguments
recursive::Bool: flag indicating whether or not tests found in subdirectories ofdirshould be included in results. Default:trueexclude_runtests::Bool: flag indicating whether or not to exclude files namedruntests.jlfrom the list of test files. Default:true
Return Values
- list of paths to Julia test files
TestTools.jltest.run_tests — Functionrun_tests(tests::Vector; kwargs...) -> Dict
run_tests(tests::AbstractString; kwargs...) -> DictRun tests in the list of files or modules provided in tests. If tests is an empty list or an empty string, an ArgumentError is thrown. File names in tests may be specified with or without the .jl extension.
Keyword Arguments
desc::AbstractString: description to use for test set used to grouptests. Default: the default description set by@testsettest_set_type::Type: type of test set to use to group tests. Whentest_set_typeis set tonothing, the tests are run individually. Default:EnhancedTestSet{DefaultTestSet}Note When the
JLTEST_FAIL_FASTenvironment variable is set to "true", thetest_set_typeargument is overridden and set toEnhancedTestSet{FallbackTestSet}so that tests are run in fail-fast mode.test_set_options::Dict: options to pass to@testsetmacrorecursive::Bool: flag indicating whether or not to run tests found in subdirectories of directories intests. Default:trueexclude_runtests::Bool: flag indicating whether or not to exclude files namedruntests.jlfrom the list of test files that are run. Default:true
Return Values
- test statistics, such as total number of passed tests, failed tests, errors, and broken tests.
TestTools.jltest.cli — Modulecli.jl defines the jltest.cli module containing functions for the jltest CLI.
Notes
- CLI functions are defined in a .jl file so that testing and code quality tools can by applied to the CLI source code.
TestTools.jltest.cli.run — Functionrun(tests::Vector; kwargs...) -> BoolRun unit tests defined in the list of files or modules provided in tests.
Keyword Arguments
fail_fast::Bool: flag indicating whether or not to stop testing at first failure. Default:falseuse_wrapper::Bool: flag indicating whether or not to run tests without first wrapping them in an EnhancedTestSet. Default:trueNote Ignored if
fail_fastis set totrue.Note Setting
use_wrappertofalsewill disable EnhancedTestSet functionality within each test files unless the test fileexplicitly sets the test set when using the
@testsetmacro orcalls
jltest.run_tests()(without setting thetest_set_typekeyword argument tonothing).
recursive::Bool: flag indicating whether or not to run tests found in subdirectories of directories intests. Default:trueverbose::Bool: print more output to the console. Default:false
Return Values
true if all tests passed; false otherwise
TestTools.jltest.cli.parse_args — Functionparse_args(; raw_args::Vector{<:AbstractString}=ARGS) -> DictParse and return CLI arguments contained in raw_args. By default, raw_args is set to ARGS, the command-line arguments provided to the executable that called parse_args().
Enabling code execution counting is not implemented within the Julia code contained in the TestTools package; it is implemented in the jltest bash script. The --code-coverage option is only included in the argument table so that it appears in the usage message.
Return Values
- parsed CLI arguments converted to Julia types
TestTools.jltest.get_wrapped_test_set_type — Functionget_wrapped_test_set_type(ts::EnhancedTestSet{T}Return type of test set wrapped by ts.
jlcoverage
TestTools.jlcoverage — ModuleThe jlcoverage module provides support for analyzing code coverage of unit tests.
TestTools.jlcoverage.display_coverage — Functiondisplay_coverage(coverage_data::Vector; startpath::AbstractString)Display coverage results provided in coverage_data. File names are displayed relative to startpath. To display absolute paths, set startpath to an empty string. By default, startpath is set to the current working directory.
TestTools.jlcoverage.cli — Modulecli.jl defines the jlcoverage.cli module containing functions for the jlcoverage CLI.
Notes
- CLI functions are defined in a .jl file so that testing and code quality tools can by applied to the CLI source code.
TestTools.jlcoverage.cli.run — Functionrun(paths::Vector; kwargs...)Run code coverage analysis for files and directories in paths.
Keyword Arguments
verbose::Bool: print more output to the console. Default:false
TestTools.jlcoverage.cli.parse_args — Functionparse_args(; raw_args::Vector{<:AbstractString}=ARGS) -> DictParse and return CLI arguments contained in raw_args. By default, raw_args is set to ARGS, the command-line arguments provided to the executable that called parse_args().
Return Values
- parsed CLI arguments converted to Julia types
jlcoverage
TestTools.jlcodestyle — ModuleThe jlcodestyle module provides support for checking and enforcing code style.
TestTools.jlcodestyle.cli — Modulecli.jl defines the jlcodestyle.cli module containing functions for the jlcodestyle CLI.
Notes
- CLI functions are defined in a .jl file so that testing and code quality tools can by applied to the CLI source code.
TestTools.jlcodestyle.cli.run — Functionrun(paths::Vector; kwargs...) -> BoolRun code style checks for files contained in paths.
Keyword Arguments
style::JuliaFormatter.AbstractStyle: code style to apply. Default:BlueStyle()overwrite::Bool: overwrite existing files with style-corrected versions. Default:falseverbose::Bool: print more output to the console. Default:false
Return Values
true if style checks pass; false otherwise
TestTools.jlcodestyle.cli.parse_args — Functionparse_args(; raw_args::Vector{<:AbstractString}=ARGS) -> DictParse and return CLI arguments contained in raw_args. By default, raw_args is set to ARGS, the command-line arguments provided to the executable that called parse_args().
Return Values
- parsed CLI arguments converted to Julia types
EnhancedTestSet
TestTools.jltest.EnhancedTestSet — Typestruct EnhancedTestSet{T<:AbstractTestSet} <: AbstractTestSetExtension of the AbstracctTestSet type that provides the following functionality:
display diffs (when available) for comparison test failures;
support fail-fast (i.e., stop testing at first failure).
TestTools.jltest.EnhancedTestSet — MethodEnhancedTestSet(description::AbstractString; kwargs...)Construct an EnhancedTestSet with the specified description.
Keyword Arguments
wrap::Type{<:AbstractTestSet}: test set type to wrap. Default:DefaultTestSet