Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
TestBox ships with a new BoxLang CLI runner for Linux/Mac and Windows. This will allow you to execute your tests from the CLI and, in the future, via VSCode easily and extremely fast. It can also execute and stream the executions so you can see the testing progress when running in verbose
mode. The runner can also execute specs/tests that are written in CFML or BoxLang in the BoxLang runtime.
Please note that this is a BoxLang-only feature.
BoxLang allows you to not only build web applications, but CLI, serverless, Android, etc. You can use this runner to test each environment. However, please note that if you will be doing web server testing from the CLI only, you will need to install the web support module into the Operating System runtime.
If you want to test from the CLI your web application with no web server, then you will need to install the bx-web-support
module into the CLI. Remember that BoxLang is multi-runtime, and you not only can build web applications but CLI or OS based applications.
This will add web support to the CLI (BIFS, components, etc.) and a mock HTTP server so you can do full life-cycle testing from the CLI like if running your app in a web server. This runner does not require a web server to function, thus if you are building a web app, you will need this module if you still want to continue to execute your tests in the CLI Runtime.
If you are building exclusively a web application, we suggest you use the CommandBox runner which will call your runner via HTTP from the CLI. You can also just use the Web Runner.
The scripts are located in the following directory: /testbox/bin
from the TestBox installation package.
run
- For Linux/Mac
run.bat
- For Windows
This is the entry point for executing tests at the CLI level. Please note that the test execution does NOT involve a web server. This is for pure CLI testing.
The runner must be run from the root of your BoxLang project:
--bundles
A list of test bundles to run, defaults to *, ex: path.to.bundle1,path.to.bundle2, . Mutually exclusive with --directory
--bundles-pattern
A pattern to match test bundles defaults to "*Spec*.cfc|*Test*.cfc|*Spec*.bx|*Test*.bx"
--directory
A list of directories to look for tests to execute. Please use dot-notation, not absolute notation. Mutually exclusive with --bundles
. Ex: tests.specs
Defaults to tests.specs
--recurse
: Recurse into subdirectories, defaults to true
--eager-failure
: Fail fast, defaults to false
--verbose
: Verbose output defaults to false. This will stream the output of the status of the tests as they run.
--runner-options
: A JSON struct literal of options to pass into the test runner. Ex: {"verbose"=true}
--reporter
The reporter to use.
--reportpath
: The path to write the report file, defaults to the /tests/results folder by convention
--properties-summary
: Generate a properties file with the summary of the test results, defaults to true.
--properties-filename
: The name of the properties file to generate defaults to TEST.properties
--write-report
: Write the report to a file in the report path folder, defaults to true
--write-json-report
: Write the report as JSON alongside the requested report, defaults to false
--write-visualizer
: Write the visualizer to a file in the report path folder, defaults to false
--labels
: A list of labels to run, defaults to *
--excludes
: A list of labels to exclude, defaults to empty
--filter-bundles
: A list of bundles to filter by, defaults to *
--filter-suites
: A list of suites to filter by, defaults to *
--filter-specs
: A list of test names or spec names to filter by, defaults to *
This is more of an approach than an actual specifc runner. This approach shows you that you can create a script file in BoxLang (bxs
) or in CFML (cfs|cfm
) that can in turn execute any test bundle(s) with many many runnable configurations.
The BoxLang language allows you to run your scripts via the CLI or the browser if you have a web server attached to your project.
If you want to run it in the CLI, then just use:
If you want to run it via the web server, place it in your /tests/
folder and run it
CFML engines only allow you to run tests via the browser. So create your script, place it in your web accessible /tests
folder and run it.
This is more of an approach than an actual specifc runner. This approach shows you that you can create a script file in BoxLang (bxs
) or in CFML (cfs|cfm
) that can in turn execute any test directory with many many runnable configurations. It is very similar to the Bundle Runner approach.
The BoxLang language allows you to run your scripts via the CLI or the browser if you have a web server attached to your project.
If you want to run it in the CLI, then just use:
If you want to run it via the web server, place it in your /tests/
folder and run it
CFML engines only allow you to run tests via the browser. So create your script, place it in your web accessible /tests
folder and run it.
By installing the CommandBox TestBox CLI you can get access to our CommandBox runner. The CommandBox runner leverages the HTTP(s) protocol to test against any server. By default it will inspect your box.json
for a default
runner or try to connect to /tests/runner.cfm
by default.
To see all the running options run the following in your CLI shell:
It can also produce reports for you in JSON, HTML, and JUNIT.
If you type testbox run --help
you can see all the arguments you can set for running your tests. However, please note that you can also pre-set them in your box.json
under the testbox
entry:
You can also set up the default runner URL in your box.json and it will be used for you. Setting the URL is a one-time operation.
You can also use a relative path and CommandBox will look up the host and port from your server settings.
The default runner URL of the testbox run
command is /tests/runner.cfm
so there's actually no need to even configure it if you're using the default convention location for your runner.
You can define multiple URLs for your runners by using a JSON array of objects. Each key will be a nice identifier you can use via the runner=key
argument in the command.
Then you can just pass in the name:
More Commands:
The CLI also comes with a code watcher and runner. It will watch any paths for you, and if it detects any changes, it will run the tests you want.
In order for this command to work, you need to have started your server and configured the URL to the test runner in your box.json
.
You can also control what files to watch.
If you need more control over what tests run and their output, you can set additional options in your box.json
which will be picked up automatically by testbox run
when it fires.
This command will run in the foreground until you stop it. When you are ready to shut down the watcher, press Ctrl+C
.
Test All Things!
TestBox tests can be run from different sources from what we call Runners. These can be from different sources:
CLI
TestBox CLI (Powered by CommandBox)
BoxLang Scripts
NodeJS
Web Server
Runner
TestBundle Directly
Custom
Your test harness already includes the web runner: runner.bx or runner.cfm
. You can execute that directly in your browser to get the results or run it via the CLI: testbox run
. We invite you to explore the different runners available to you.
However, you can create your own custom runners as long as you instantiate the TestBox
class and execute one of it's runnable methods. The main execution methods are:
We encourage you to read the API docs included in the distribution for the complete parameters for each method.
run()
Here are the arguments you can use for initializing TestBox or executing the run()
method
The bundles
argument which can be a single CFC path or an array of CFC paths or a directory argument so it can go and discover the test bundles from that directory.
The reporter
argument can be a core reporter name like: json,xml,junit,raw,simple,dots,tap,min,etc or it can be an instance of a reporter CFC.
You can execute the runners from any cfm template or any CFC or any URL, that is up to you.
There is a user-contributed NodeJS Runner that looks fantastic and can be downloaded here: https://www.npmjs.com/package/testbox-runner
You can use node to install as well into your projects.
Create a config file called .testbox-runnerrc
in the root of your web project.
Then use the CLI command to run whatever you configured.
testbox-runner
You can also specify a specific configuration file:
testbox-runner --config /path/to/config/file.json
Simply run the utility and pass the above configuration options prefixed with --
.
Example
TestBox ships with a test browser that is highly configurable to whatever URL accessible path you want. It will then show you a test browser where you can navigate and execute not only individual tests, but also directory suites as well.
BoxLang: /testbox/bx/test-browser
CFML: /testbox/cfml/test-browser
It is also a mini web application that can be configured to whatever root folder you desire. It will read the runners and tests from that folder and present a GUI that you can use to navigate the test folders and execute them easily.
TestBox ships with a global runner that can be used to run pretty much anything. You can customize it or place it wherever you need it. You can find it in your distribution under:
BoxLang: /testbox/bx/test-browser
CFML: /testbox/cfml/test-browser
This is a mini web application to help you run bundles, directory, specs and more.
Every test harness comes with a runner.bx or runner.cfm
in the root of the tests
folder. This is called the web runner and is executable via the web server you are running your application on. This will execute all the tests by convention found in the tests/specs
folder.
You can open that file and customize it as you see fit. Here is an example of such a file:
If you make your test bundle class inherit from our testbox.system.BaseSpec
class, you will be able to execute the class directly via the URL:
All the arguments found in the runner
are available as well in a direct bundle execution:
labels
: The labels to apply to the execution
testMethod
: A list or array of xunit test names that will be executed ONLY!
testSuites
: A list or array of suite names that are the ones that will be executed ONLY!
testSpecs
: A list or array of test names that are the ones that will be executed ONLY!
reporter
: The type of reporter to run the test with
In our test harness we include an ANT runner (test.xml
) that will be able to execute your tests via ANT.
Ant is a Java-based build tool from Apache designed to automate the software build process. Unlike traditional build tools that rely on shell commands, Ant uses XML to describe the build process and its dependencies, making it platform-independent and flexible. It is particularly useful for Java projects to compile code, manage dependencies, and create deployment packages.
It can also leverage our ANTJunit
reporter to use the junitreport
task to produce JUnit compliant reports as well.
Now you can run the commands