Testing
The plugin supports the NPL test suite. To make a test, create a new file, preferably in a "Test sources root" directory. A test is a function that satisfies the following criteria:
- It is annotated with
@test
, - It has a single parameter named
test
of typeTest
, - Its return type is
Unit
.
To run tests, click the gutter icon next to the test annotation and select the appropriate option. Note that the action is not available when the indices are being updated. All tests in the given file will be executed and a test report produced in the test window. The names of functions in the test window are navigable, i.e. you can click on them and it will show the function body. The description of a failed test will be displayed in the window right of the tree of the tests.
For failed assertions, the NPL stack trace is output and is navigable.
To run tests in all the files, you need to create a run configuration first. Select Run | Edit Configurations ...
.
Click +
in the upper left corner, and select NPL Tests
. Change the name Unnamed
to something meaningful, e.g.
Test All
and now close the window.
Now you can run the Test All
configuration through Run | Run ...
or through the Run Configuration
box in your
toolbar.
Note: The files under test are compiled before tests are run. If the compilation fails, no tests are run. Keep in
mind that the compilation process applies only to files under Sources root
or Test Sources root
, not under
Resources root
.