Robolectric Configuration

Robolectric configuration for Android unit tests

What is it?

Roboletric is a framework for unit testing on Android. One of its functions is to simulate information about Android’s context during the tests performed.

It’s necessary to configure a dependency of Yoga Layout called SoLoader, that, if it’s not enabled as TEST mode, a nullPointerException error will occur, since the view will not exist in that context.

Therefore, the SDK is configured to activate “TesteMode” in SoLoader when starting a test and deactivating it when finished. To do so, just use the functions as indicated below.

How to configure?

To configure Beagle in for robolectric tests, add the code below in your test case:

@BeforeClass
fun setup() {
    BeagleSdk.setInTestMode()
}

@AfterClass
fun teardown() {
    BeagleSdk.deinitForTest()
}

Last modified February 11, 2021: create content (#298) (43225e15)