testkit-gradle-plugin

Testkit plugin for custom Android Gradle plugin testing

Лицензия

Лицензия

Категории

Категории

Gradle Компиляция и сборка
Группа

Группа

io.bootstage.testkit
Идентификатор

Идентификатор

testkit-gradle-plugin
Последняя версия

Последняя версия

1.4.0
Дата

Дата

Тип

Тип

module
Описание

Описание

testkit-gradle-plugin
Testkit plugin for custom Android Gradle plugin testing
Ссылка на сайт

Ссылка на сайт

https://github.com/bootstage/testkit-gradle-plugin
Система контроля версий

Система контроля версий

https://github.com/bootstage/testkit-gradle-plugin

Скачать testkit-gradle-plugin

Зависимости

compile (2)

Идентификатор библиотеки Тип Версия
org.jetbrains.kotlin : kotlin-test jar 1.3.72
org.jetbrains.kotlin : kotlin-test-junit jar 1.3.72

runtime (2)

Идентификатор библиотеки Тип Версия
org.jetbrains.kotlin : kotlin-stdlib-jdk8 jar 1.3.72
com.didiglobal.booster : booster-build jar 2.4.0

Модули Проекта

Данный проект не имеет модулей.

Introduction

Android developers might be use Android Gradle plugin's internal API to build custom gradle plugins for Android project, the idea is great, but the internal API of Android Gradle plugin is unstable, in fact, the internal API of each major release of Android Gradle plugin always has significant changes, It takes too much efforts on compatibility testing.

The goal of testkit-gradle-plugin is to make the custom Android gradle plugin testing easier and more efficient

Getting Started

Create gradle project structure

Create Gradle project structure under Java resources directory

src/integrationTest/resources
├── build.gradle
└── src
    └── main
        └── java
            └── main.kt

build.gradle

plugins {
    id 'org.jetbrains.kotlin.jvm' version '1.3.72'
    id 'io.bootstage.testkit' version '1.3.0'
}

repositories {
    mavenLocal()
    google()
    mavenCentral()
    jcenter()
}

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib:1.3.72"
}

compileKotlin {
    kotlinOptions {
        jvmTarget = "1.8"
    }
}

compileTestKotlin {
    kotlinOptions {
        jvmTarget = "1.8"
    }
}

apply from: "$rootDir/gradle/integration-test.gradle"

gradle/integration-test.gradle

sourceSets {
    integrationTest {
        java {
            srcDirs += []
        }
        kotlin {
            srcDirs += ['src/integrationTest/kotlin', 'src/integrationTest/java']
        }
        resources.srcDir file('src/integrationTest/resources')
        compileClasspath += sourceSets.main.output + configurations.testRuntime
        runtimeClasspath += output + compileClasspath
    }
}

configurations {
    integrationTestImplementation.extendsFrom testImplementation
    integrationTestRuntimeOnly.extendsFrom testRuntimeOnly
}

task integrationTest(type: Test) {
    description = 'Runs the integration tests.'
    group = 'verification'
    testClassesDirs = sourceSets.integrationTest.output.classesDirs
    classpath = sourceSets.integrationTest.runtimeClasspath
    mustRunAfter test
}

check.dependsOn integrationTest

compileIntegrationTestKotlin {
    kotlinOptions.jvmTarget = JavaVersion.VERSION_1_8
}

gradlePlugin {
    testSourceSets sourceSets.integrationTest
}

Write test code

class SimpleIntegrationTest {

    private val projectDir: TemporaryFolder = TemporaryFolder()

    @get:Rule
    val chain: RuleChain = rule(projectDir) { projectDir ->
        GradleExecutor(projectDir::getRoot)
    }

    @Test
    @Case(SimpleTestCase::class)
    fun `test gradle build`() {
        projectDir.copyFromResource("build.gradle")
        projectDir.copyFromResource("src")
    }

}

class SimpleTestCase : TestCase {
    override fun apply(project: Project) {
        project.projectDir.walkTopDown().forEach(::println)
    }
}

Run tests

Running test by executing the following command:

./gradlew cleanTest integrationTest
io.bootstage.testkit

bootstage

Версии библиотеки

Версия
1.4.0
1.3.0
1.2.0
1.1.0
1.0.0