Skip to content

Commit

Permalink
feat(test): spring-boot-starter-test默认依赖由ihub-test插件转移至ihub-spring (#747
Browse files Browse the repository at this point in the history
)

Signed-off-by: henry <[email protected]>
  • Loading branch information
henry-hub authored Jan 28, 2024
1 parent cc87064 commit 89d2f2b
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022-2023 the original author or authors.
* Copyright (c) 2022-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -23,6 +23,7 @@ import org.springframework.boot.gradle.tasks.run.BootRun
import pub.ihub.plugin.IHubPlugin
import pub.ihub.plugin.IHubPluginsExtension
import pub.ihub.plugin.IHubProjectPluginAware
import pub.ihub.plugin.bom.IHubBomExtension
import pub.ihub.plugin.java.IHubJavaPlugin

import static org.springframework.boot.buildpack.platform.build.PullPolicy.IF_NOT_PRESENT
Expand All @@ -40,6 +41,10 @@ class IHubBootPlugin extends IHubProjectPluginAware<IHubBootExtension> {

@Override
void apply() {
withExtension(IHubBomExtension).dependencies {
testImplementation 'org.spockframework:spock-spring'
testRuntimeOnly 'org.springframework.boot:spring-boot-starter-test'
}
withExtension(AFTER) { ext ->
withTask(BootRun) {
ext.systemProperties it, '.boot-java-local.properties'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022-2023 the original author or authors.
* Copyright (c) 2022-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -37,6 +37,8 @@ class IHubBootPluginTest extends IHubSpecification {
def result = gradleBuilder.build()

then: '检查结果'
result.output.contains '│ testImplementation │ org.spockframework:spock-spring │'
result.output.contains '│ testRuntimeOnly │ org.springframework.boot:spring-boot-starter-test │'
result.output.contains 'BUILD SUCCESSFUL'

when: '构建项目'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ class IHubTestPlugin extends IHubProjectPluginAware<IHubTestExtension> {
(SPOCK) : { IHubBomExtension iHubBom ->
applyPlugin GroovyPlugin
iHubBom.dependencies {
testImplementation 'org.spockframework:spock-spring'
testRuntimeOnly 'com.athaydes:spock-reports', 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.spockframework:spock-core'
testRuntimeOnly 'com.athaydes:spock-reports'
}
},
(JUNIT_JUPITER): { IHubBomExtension iHubBom ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ class IHubVerificationPluginTest extends IHubSpecification {
result = gradleBuilder.withArguments('-DiHubTest.runSkippedPropNames=java.endorsed.dirs').build()

then: '检查结果'
!result.output.contains('│ testImplementation │ org.spockframework:spock-spring │')
!result.output.contains('│ testRuntimeOnly │ com.athaydes:spock-reports')
!result.output.contains('org.spockframework:spock-core')
!result.output.contains('com.athaydes:spock-reports')
result.output.contains '│ pmd │ com.alibaba.p3c:p3c-pmd │'
result.output.contains 'BUILD SUCCESSFUL'

Expand All @@ -113,10 +113,9 @@ class IHubVerificationPluginTest extends IHubSpecification {
result = gradleBuilder.withArguments('-DiHubTest.runIncludePropNames=java.endorsed.dirs').build()

then: '检查结果'
result.output.contains '│ testImplementation │ org.spockframework:spock-spring │'
result.output.contains '│ testRuntimeOnly │ com.athaydes:spock-reports │'
result.output.contains '│ testRuntimeOnly │ org.springframework.boot:spring-boot-starter-test │'
result.output.contains '│ pmd │ com.alibaba.p3c:p3c-pmd │'
result.output.contains '│ testImplementation │ org.spockframework:spock-core │'
result.output.contains '│ testRuntimeOnly │ com.athaydes:spock-reports │'
result.output.contains '│ pmd │ com.alibaba.p3c:p3c-pmd │'
result.output.contains 'BUILD SUCCESSFUL'
}

Expand All @@ -137,10 +136,9 @@ class IHubVerificationPluginTest extends IHubSpecification {
def result = gradleBuilder.build()

then: '检查结果'
result.output.contains '│ testImplementation │ org.spockframework:spock-spring │'
result.output.contains '│ testRuntimeOnly │ com.athaydes:spock-reports │'
result.output.contains '│ testRuntimeOnly │ org.springframework.boot:spring-boot-starter-test │'
result.output.contains '│ pmd │ com.alibaba.p3c:p3c-pmd │'
result.output.contains '│ testImplementation │ org.spockframework:spock-core │'
result.output.contains '│ testRuntimeOnly │ com.athaydes:spock-reports │'
result.output.contains '│ pmd │ com.alibaba.p3c:p3c-pmd │'
result.output.contains 'BUILD SUCCESSFUL'
}

Expand Down

0 comments on commit 89d2f2b

Please sign in to comment.