BatchRunner is a Junit plugin that is composed on top of Coroutines to bring parallelism to the UnitTests.
With this plugin, you can leverage the maximum threads available in your machine (CI - Instance).
BatchRunner also supports SuiteTests, in the sense that you will be able to run different test classes in the suite parallelly.
Add the following to your project's root build.gradle file
repositories {
maven {
url "https://jitpack.io"
}
}
Add the following to your project's build.gradle file
dependencies {
testImplementation("com.github.iamjosephmj:BatchRunner:1.0.1")
}
@RunWith(BatchRunner::class)
class BatchRunnerUnitTest1 {
@Test
fun addition_isCorrect() {
assertEquals(4, 2 + 2)
}
// along with you tests
}
@RunWith(MockitoJUnitBatchRunner::class)
class MockitoBatchTest {
@Mock
private lateinit var context: Context
@Before
fun before() {
`when`(context.isRestricted).thenReturn(true)
}
@Test
fun mockTest1() {
assert(context.isRestricted)
}
}
@RunWith(BatchSuite::class)
@BatchSuite.SuiteClasses(
BatchRunnerUnitTest1::class,
BatchRunnerUnitTest2::class
)
class BatchSuiteRunner
android {
subprojects {
tasks.withType<Test> {
maxParallelForks = Runtime.getRuntime().availableProcessors()
}
}
}
If part of BatchRunner is not working correctly be sure to file a Github issue. In the issue provide as many details as possible. This could include example code or the exact steps that you did so that everyone can reproduce the issue. Sample projects are always the best way :). This makes it easy for me or someone from the open-source community to start working!
If you have a feature idea submit an issue with a feature request or submit a pull request and we will work with you to merge it in!
Contributions are more than welcome!
- You should make sure that all the test are working properly.
- You should raise a PR to
develop
branch - Before you raise a PR please make sure your code had no issue from Android studio lint analyzer.