I am developer a Gradle plugin. My plugin depends on the Android Gradle plugin. My plugin adds an action to some Android Gradle tasks and some tasks of it's own based on the application variant.
public class MyPlugin implements Plugin<Project> {
@Override
void apply(Project project) {
project.android.applicationVariants.all {
project.task(type: SendApkTask, dependsOn: it.assemble, "send${it.name.capitalize()}Apk")
}
}
}
I want to create a unit test for MyPlugin#apply(Project).
public class MyPluginTest {
Project project
@Before
public void setup() {
project = ProjectBuilder.builder().build()
}
@Test
public void testMyPluginAddsTasks() {
project.apply plugin: 'com.android.application'
project.apply plugin: CsPlugin
assertNotNull(project.tasks['sendReleaseApk'])
}
}
I can not get this assertion to pass. After debugging I found that project.applicationVariants
is empty. How do I get the Android Gradle Plugin mocked effectively for my test?
Aucun commentaire:
Enregistrer un commentaire