-
Notifications
You must be signed in to change notification settings - Fork 29
Creating test suites
Rooibos has a hiearchy of tests as follows:
- Suite
- Describe block
- it test
- Parameterized it test
- it test
- Describe block
Test suites are defined by:
- declaring a class inside a namespace
- which extends
Rooibos.BaseTestSuite
- and has a
@suite
annotation
No special file naming is required. I recommend you call your files thing.spec.bs
Please note that rooibos tests are brighterscript only. You can test regular brs files; but all your tests must be brightersript files.
I find it really handy to have my own BaseTestSuite, that extends Rooibos.BaseTestSuite
and I use that as the base of all my tests. In this way I can easily use common utilities and use common beforeEach/setup for setting things up.
The following is a minimum working example of a Rooibos test suite, named Simple.brs
namespace tests
@suite("basic tests")
class BasicTests extends Rooibos.BaseTestSuite
'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
@describe("tests the node context is available for a Node scope function")
'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
@it("does something in node scope")
function _()
m.assertNotInvalid(m.node)
Tests.doSomethingInNodeScope(true)
m.assertInvalid(m._isNodeScopeVarSet)
m.assertTrue(m.node._isNodeScopeVarSet)
end function
end class
end namespace
- The
++++++++++++
's around the@describe
declaration are not required; but I find it makes the file much easier to read, and recommend it (or something similar, such as'*****
as a best practice. - If you do not provide names for the
@suite
it will use the class name - The function name is not required. Rooibos will rename your function to whatever your describe group is (so you can easily navigate in the ide), and as such, the function name cann be anything you like. I like calling all tests functions
_
. Don't worry - the plugin will rename it before you get any duplicate function errors!
Rooibos provides a library of annotations which can be used to define test suites, describe groups, tests cases, Parameterized tests, and more. All annotations are of the following form
NOTE - these are official bsc compiler annotations; not like comments in the previous version of rooibos do not put a '
in front of the, and use @brighterscript("argument1", 2, "argument3", ["syntax])
@annotation(args...)
Where ANNOTATION
, is the roku annotation and DATA is the data passed to it. e.g. @it("that it handles an empty collection")
, defines a test case, with the title that it handles an empty collection
Some annotations act as modifiers. In these cases, they will affect some other annotation. For example @only
, and @ignore
will affect the following @suite
, @it
or @it
annotation.
The following annotations are supported.