-
Notifications
You must be signed in to change notification settings - Fork 1
DTest
]DTest can be used to perform automated testing (thus supporting continuous integration).
The simplest form of a test is a .dyalog (or .aplf) file containing a test-function. Typically you will not write a few large test-functions but rather many small test-fns that focus on testing one specific function per test-fn.
Tests or test-suites are executed by launching ]DTest <arg>.
arg is one of:
- ns: namespace in the current workspace
- file: a .dyalog file containing a namespace or a test-fn
- path: path to directory containing functions in .dyalog or .aplf files
The following switches and modifiers can be used to control the behaviour:
-
-clear[=n]: clear ws before running tests (optionally delete nameclassnonly) -
-coverage: enable analysis of code coverage -
-filter=String: only run functions whose name start with filter (accepts wildcards*and *?`) -
-halt: halt on error rather than log and continue -
-init: if specified test-file (.dyalog or .dyalogtest) wasn't found, it will be initialised with a template. -
-loglvl: control which log files we create (if value of "-off" > 0)1={base}.log: errors 2={base}.warn.log warnings 4={base}.info.log info 8={base}.session.log 16={base}.session.log ONLY if test failed 32={base}.log.json: machine-readable results Creating such a log is the ONLY way to get data on performance and memory usage of tests! (Values are bit flags, so options can be added) -
-off: exits APL after running the test. Returncode 20 indicates "no errors", 21 means "test failed". (Any other value (including 0!) would be signaled outside of DTest and indicate other kind of failure!) If the test(s) failed, a logfile will be created in the same folder as the test. (Same filename as the suite with extension ".log") -
-order=0|1|"NumVec": control sequence of tests (default 0: random; 1:sequential;"NumVec":order) (TecNote) -
-quiet: qa mode: only output actual errors -
-repeat=n: repeat test n times -
-setup=fn: run the function fn before any tests (by default, if a folder or a.dyalog-file is given inarg, all functions whose names being withsetup_will be used. -
-successvalue=string: return value to expect when a test was successful. (Please read dedicated page for more!) (V1.70) -
-suite=file: run tests defined by a .dyalogtest file -
-teardown=fn: run the function fn after all tests -
-testlog=file: force name of logfile(s) (default name of testfile) -
-tests=: comma-separated list of tests to run -
-timeout=n: sets a timeout. Seconds after which test(suite)s will be terminated. (Default=0 means: no timeout) -
-ts: add timestamp (no date) to logged messages -
-trace: set stop on line 1 of each test function -
-verbose: display more status messages while running
Additionally, v1.31 introduced the possibility to provide up to 999 elements in arg. Processing these additional elements would then be done by the test itself. Your test-function may use ⍴##.args.Arguments to see the number of arguments provided. ##.args.Arguments[1] is used by the ]DTest, the others can be "consumed" as you wish. (As an example, we used this in the DUI-Tests to select the test to execute.)