Standalone mocks for brightscript. It works with Roku's Unit Test Framework and can work with any brightscript test framework.
- Clone or Fork the code from the github repo
- Delete the rMock.brs file found under the source branch ( This file is generated automatically and is not needed when making changes to the main code base. )
- Deploy code to device
- This should display a blank page. You'd have to see the test results on your telnet port: <DEVICE_IP>:8085. You can find more information on debugging here
To include the rMock library in your actual testsuite, you will need to copy the rMock.brs file found on the /source
folder. Make sure to include this file within /source
folder on your project. It can be placed within any subfolder under /source
You can find more as to how to use the Mock
library from the documentation.
To generate rMock.brs
, you need to have node
and npm
installed. Once you have both running in your environment, Simply running node scripts.js
would create the rMock.brs file. The purpose of this file is to create a single file code base that could be dropped in like a library in the main project.
A text editor to make changes and a roku device to deploy the program onto.
We recommend using Atom as your code editor of choice for the following and using the Roku Develop plugin to make your deployments.
Alternatively, you can follow the standard deployment procedure as well
Use the Mock
method to create a mock object to be used as a dependency on the subject under test.
You can find an example of how the mock object is used below. More detailed docs about the Mock, Expectation and Actions object can be found in the docs section.
function TestCase_DisplayMeasurement()
' Set up
mockUnitConvertor = Mock( UnitConversionService() )
mockUnitConvertor.when("lbToKg").returns(1.81437)
mockUnitConvertor.expects("lbTokg").once().withArguments( [ 4.0 ] )
' Exercise
scale = ScaleService( mockUnitConvertor.proxy() )
scale.Measure( "lb", 4 )
measurement = scale.DisplayMeasurement( "kg" )
' Verify
mockStatus = mockUnitConvertor.verify()
isEquals = ( measurement = "1.81437kg" )
return m.assertTrue( ( mockStatus AND isEquals ) )
end function
Please find the coding and commit formatting styles within contributing section
We use SemVer for versioning. For the versions available, see the tags on this repository.
- Mark Jefferson Arthur - Initial work - Tribalscale
- Mark Zou - Initial work - Tribalscale
See also the list of contributors who participated in this project.
This project is licensed under the Apache License - see the LICENSE.md file for details
- The mock framework builds on the work described on the paper Endo Testing - Unit Testing with Mock Objects. Everything mentioned in the paper has not been accomplished but the most basic level needed for brightscript has been implemented.
- We looked at several popular mock frameworks out in the market for other languages ( JMock, EasyMock, Jest, Jasmine, Sinon.js...etc )
- A special mention to the article written by Martin Fowler and Uncle Bob. Their teaching has served us understand the craft of building software.