1. Mark Roddy
  2. brstest


Clone wiki

brstest / QuickStart

Below is short description to get started writing tests using brstest.

  1. Obtain a copy of the latest brstest.brs which can be found via the Downloads tab above and place it in the sources directory of your project.
  2. Modify the Main() method for your project to BrsTestMain()
  3. Create a new file in your sources directory named test_example.brs
  4. Place the following code in the file which you just created:
Sub testAddition(t as object)
    a = 1
    b = 2
    t.assertEqual(3, a + b)
    t.assertNotEqual(4, a+b)
End Sub

Sub testWillFail(t as object)
    f = false
End Sub

Sub testWillError(t as object)
    x = 0
    y = 1
    i = y / x 
End Sub

When you deploy your application, you should see output similar to the following your debug console:

------ Running ------
ERROR: testWillError
FAIL: testWillFail
expression evaluates to false
Ran 3 tests
FAILED (failures= 1, errors= 1)    

As you can see, the three tests were executed with the failing assert and run time error being trapped and reported by the test framework. You should now be able to start writing your own tests remembering two things:

  1. Both files with test methods and the names of the methods you wish to be executed must begin with 'test' or they will not be found by the test framework.
  2. Your test methods must take a single argument of type object or calls to your test method will fail.

If you want more information on writing tests or you get stuck on behavior you don't understand try reading the BrstTestConcepts article. If you're still having issues after this, it's suggested that you post questions on the Roku SDK forum.