mirror of
https://github.com/alibaba/testable-mock.git
synced 2025-02-13 13:20:32 +08:00
fully support gradle build and test
This commit is contained in:
parent
472f90e7e4
commit
001001bfd3
@ -12,9 +12,9 @@ repositories {
|
||||
|
||||
dependencies {
|
||||
testImplementation('org.junit.jupiter:junit-jupiter:5.6.2')
|
||||
testImplementation('com.alibaba.testable:testable-processor:0.3.2-SNAPSHOT')
|
||||
testAnnotationProcessor('com.alibaba.testable:testable-processor:0.3.2-SNAPSHOT')
|
||||
testRuntimeOnly('com.alibaba.testable:testable-agent:0.3.2-SNAPSHOT')
|
||||
testImplementation('com.alibaba.testable:testable-processor:0.3.2')
|
||||
testAnnotationProcessor('com.alibaba.testable:testable-processor:0.3.2')
|
||||
testRuntimeOnly('com.alibaba.testable:testable-agent:0.3.2')
|
||||
}
|
||||
|
||||
test {
|
||||
|
34
demo/kotlin-demo/build.gradle.kts
Normal file
34
demo/kotlin-demo/build.gradle.kts
Normal file
@ -0,0 +1,34 @@
|
||||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||
|
||||
plugins {
|
||||
kotlin("jvm") version "1.4.10"
|
||||
}
|
||||
|
||||
group = "com.alibaba.testable"
|
||||
version = "1.0.0-SNAPSHOT"
|
||||
java.sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation("org.jetbrains.kotlin:kotlin-reflect")
|
||||
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
|
||||
testImplementation("org.junit.jupiter:junit-jupiter:5.6.2")
|
||||
testImplementation("com.alibaba.testable:testable-processor:0.3.2")
|
||||
testAnnotationProcessor("com.alibaba.testable:testable-processor:0.3.2")
|
||||
testRuntimeOnly("com.alibaba.testable:testable-agent:0.3.2")
|
||||
}
|
||||
|
||||
tasks.withType<KotlinCompile> {
|
||||
kotlinOptions {
|
||||
freeCompilerArgs = listOf("-Xjsr305=strict")
|
||||
jvmTarget = "1.8"
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType<Test> {
|
||||
jvmArgs("-javaagent:${classpath.find { it.name.contains("testable-agent") }!!.absolutePath}")
|
||||
useJUnitPlatform()
|
||||
}
|
1
demo/kotlin-demo/settings.gradle.kts
Normal file
1
demo/kotlin-demo/settings.gradle.kts
Normal file
@ -0,0 +1 @@
|
||||
rootProject.name = "demo"
|
@ -60,15 +60,17 @@
|
||||
<argLine>@{argLine} -javaagent:${settings.localRepository}/com/alibaba/testable/testable-agent/${testable.version}/testable-agent-${testable.version}.jar</argLine>
|
||||
```
|
||||
|
||||
参见项目`java-demo`的[pom.xml](https://github.com/alibaba/testable-mock/blob/master/demo/java-demo/pom.xml)和`kotlin-demo`的[pom.xml](https://github.com/alibaba/testable-mock/blob/master/demo/kotlin-demo/pom.xml)文件。
|
||||
|
||||
## 在Gradle项目中使用
|
||||
|
||||
在`build.gradle`文件中添加TestableMock依赖:
|
||||
|
||||
```groovy
|
||||
dependencies {
|
||||
testImplementation('com.alibaba.testable:testable-processor:0.3.1')
|
||||
testAnnotationProcessor('com.alibaba.testable:testable-processor:0.3.1')
|
||||
testRuntimeOnly('com.alibaba.testable:testable-agent:0.3.1')
|
||||
testImplementation('com.alibaba.testable:testable-processor:0.3.2')
|
||||
testAnnotationProcessor('com.alibaba.testable:testable-processor:0.3.2')
|
||||
testRuntimeOnly('com.alibaba.testable:testable-agent:0.3.2')
|
||||
}
|
||||
```
|
||||
|
||||
@ -80,4 +82,4 @@ test {
|
||||
}
|
||||
```
|
||||
|
||||
> 注意:由于Gradle的构建与测试运行机制与Maven稍有差异,当前在Gradle项目里,`@PrivateAccessor`注解和`TestableTool.TEST_CASE`功能存在已知BUG,其余功能均可正常使用
|
||||
参见项目`java-demo`的[build.gradle](https://github.com/alibaba/testable-mock/blob/master/demo/java-demo/build.gradle)和`kotlin-demo`的[build.gradle.kts](https://github.com/alibaba/testable-mock/blob/master/demo/kotlin-demo/build.gradle.kts)文件。
|
||||
|
Loading…
Reference in New Issue
Block a user