[fenix] For https://github.com/mozilla-mobile/fenix/issues/9605: add FenixRobolectricTestRunner.
This class will help us reduce duplication by specifying the configuration within the test runner rather than each test needing to specify it itself. This class is adapted from Firefox for Fire TV: https://github.com/mozilla-mobile/firefox-tv/blob/master/app/src/test/java/org/mozilla/tv/firefox/helpers/FirefoxRobolectricTestRunner.ktpull/600/head
parent
774a07d5f7
commit
b401d400b3
@ -0,0 +1,32 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
package org.mozilla.fenix.helpers
|
||||
|
||||
import org.mozilla.fenix.TestApplication
|
||||
import org.robolectric.RobolectricTestRunner
|
||||
import org.robolectric.annotation.Config
|
||||
|
||||
/**
|
||||
* A test runner that starts Robolectric with our custom configuration for use in unit tests.
|
||||
*
|
||||
* usage:
|
||||
* ```
|
||||
* @RunWith(FenixRobolectricTestRunner::class)
|
||||
* class ExampleUnitTest {
|
||||
* ```
|
||||
*
|
||||
* IMPORTANT NOTES:
|
||||
* - This should ALWAYS be used instead of RobolectricTestRunner and AndroidJUnit4 (note: the latter
|
||||
* just delegates to the former)
|
||||
* - You should only use Robolectric when necessary because it non-trivially increases test duration.
|
||||
*/
|
||||
class FenixRobolectricTestRunner(testClass: Class<*>) : RobolectricTestRunner(testClass) {
|
||||
|
||||
override fun buildGlobalConfig(): Config {
|
||||
return Config.Builder()
|
||||
.setApplication(TestApplication::class.java)
|
||||
.build()
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue