Refactor TestBuildInfoPluginFuncTest for clarity (#128469)

* Refactor TestBuildInfoPluginFuncTest for clarity

* Further simplify TestBuildInfoPluginFuncTest
This commit is contained in:
Patrick Doyle 2025-05-27 13:50:26 -04:00 committed by GitHub
parent 0404c077de
commit a78f1f04b7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -39,17 +39,6 @@ class TestBuildInfoPluginFuncTest extends AbstractGradleFuncTest {
} }
""" """
when:
def result = gradleRunner('generateTestBuildInfo').build()
def task = result.task(":generateTestBuildInfo")
then:
task.outcome == TaskOutcome.SUCCESS
def output = file("build/generated-build-info/plugin-test-build-info.json")
output.exists() == true
def location = Map.of( def location = Map.of(
"module", "com.example", "module", "com.example",
"representative_class", "com/example/Example.class" "representative_class", "com/example/Example.class"
@ -58,6 +47,15 @@ class TestBuildInfoPluginFuncTest extends AbstractGradleFuncTest {
"component", "example-component", "component", "example-component",
"locations", List.of(location) "locations", List.of(location)
) )
def output = file("build/generated-build-info/plugin-test-build-info.json")
when:
def result = gradleRunner('generateTestBuildInfo').build()
then:
result.task(":generateTestBuildInfo").outcome == TaskOutcome.SUCCESS
output.exists() == true
new ObjectMapper().readValue(output, Map.class) == expectedOutput new ObjectMapper().readValue(output, Map.class) == expectedOutput
} }
@ -87,16 +85,7 @@ class TestBuildInfoPluginFuncTest extends AbstractGradleFuncTest {
} }
""" """
when:
def result = gradleRunner('generateTestBuildInfo').build()
def task = result.task(":generateTestBuildInfo")
then:
task.outcome == TaskOutcome.SUCCESS
def output = file("build/generated-build-info/plugin-test-build-info.json") def output = file("build/generated-build-info/plugin-test-build-info.json")
output.exists() == true
def locationFromModuleInfo = Map.of( def locationFromModuleInfo = Map.of(
"module", "org.objectweb.asm", "module", "org.objectweb.asm",
@ -115,7 +104,12 @@ class TestBuildInfoPluginFuncTest extends AbstractGradleFuncTest {
"locations", List.of(locationFromModuleInfo, locationFromManifest, locationFromJarFileName) "locations", List.of(locationFromModuleInfo, locationFromManifest, locationFromJarFileName)
) )
def value = new ObjectMapper().readValue(output, Map.class) when:
value == expectedOutput def result = gradleRunner('generateTestBuildInfo').build()
then:
result.task(":generateTestBuildInfo").outcome == TaskOutcome.SUCCESS
output.exists() == true
new ObjectMapper().readValue(output, Map.class) == expectedOutput
} }
} }