In order to make sure a method works correctly, a test can be implemented that assures the correct behavior.
It is a common practice to write tests to clarify how an object should respond, and it may avoid inconsistencies on the long run. A test is always a subclass of UnitTest
, implementing at least one method starting with test_
.
testsuite/classlibrary
directory of the SuperCollider sources.
To install, download the sources and add the directory to your sclang_conf.yaml
, either by editing it or via the ScIDE preferences.
A graphical interface to run and browse all tests
Accessor controlling whether passing tests should be reported. Defaults to true
. See also *passVerbosity which controls how much detail is reported from passing tests when this is set to true.
(value) |
Should be |
Accessor controlling whether extra details should be reported for passing tests.
Defaults to UnitTest.full
so that all details are reported; however this behaviour may be too verbose for some, for whom it is sufficient to see that a test is passing without needing to see the detail. If set to UnitTest.brief
, and *reportPassesis true, passes will be reported, but without any extra details which may be provided by assertions.
(value) |
Should be |
Run all methods whose names begin with test_
.
reset |
If |
report |
If |
Run a single test method.
methodName |
A String referring to the class and test method within it, e.g. |
runs all subclasses of UnitTest
Run a single test method of this class
method |
the method to run |
(describe returnvalue here)
Asserts that an expression must be true.
boolean |
A boolean, where |
message |
A message describing the purpose of the assertion, e.g. |
report |
Reports the result of the test if |
onFailure |
If not |
details |
Some optional extra details which will be passed to the reporting framework for display unless brief reporting is requested (see *passVerbosity). |
Asserts that an expression a
is equal to the value b
, where equality is determined according to a
's implementation of ==
.
Automatically passes details of the equality check to the reporting framework, which will be displayed if the assertion fails, and also if it passes and *reportPasses is true
and *passVerbosity is not set to UnitTest.brief
.
a |
the experimentally produced value |
b |
the expected value |
message |
A message describing the purpose of the assertion, e.g. |
report |
Reports the result of the test if |
onFailure |
If not |
Asserts that an expression a
returning a float is within a given range (within
) of being equal to b
.
Automatically passes details of the equality check to the reporting framework, which will be displayed if the assertion fails, and also if it passes and *reportPasses is true
and *passVerbosity is not set to UnitTest.brief
.
a |
the experimentally produced float value |
b |
the expected float value |
message |
A message describing the purpose of the assertion, e.g. |
within |
The range within which |
report |
Reports the result of the test if |
onFailure |
If not |
Make sure that the two arrays of floats a
and b
equal within a given range (within
).
a |
the experimentally produced value, which is an |
b |
the |
message |
A message describing the purpose of the assertion, e.g. |
within |
The range within which each item of |
report |
Reports the result of the test if |
onFailure |
If not |
Make a further assertion only if it passed, or only if it failed.
Wait for a condition, consider failed after maxTime. Only valid within a test (or a routine).
Wait for server boot until continued. Only valid within a test (or a routine).
If already booted, then freeAll and create new allocators.
Register a passed test.
method |
Name of the method in which the test is passing. |
message |
A message describing the purpose of the assertion, e.g. |
report |
Reports the result of the test if true and *reportPasses is true. |
details |
Some optional extra details which will be displayed if *reportPasses is true and *passVerbosity is not set to |
Register a test failure.
method |
Name of the method in which the test is failing. |
message |
A message describing the purpose of the assertion, e.g. |
report |
Reports the result of the test if true. |
details |
Some optional extra details which will be displayed if |
Write tests by subclassing UnitTest, and defining methods whose names begins test_
. Each test method will be called from a fresh instance of the subclass.
If you implement the methods setUp
and tearDown
in your test class, they will be called before and after every test. This can help to eliminate repetitive code, and makes it easier to maintain your tests by ensuring that they all run under the same set of conditions.