Skip to content

Commit a78f1f0

Browse files
authored
Refactor TestBuildInfoPluginFuncTest for clarity (#128469)
* Refactor TestBuildInfoPluginFuncTest for clarity * Further simplify TestBuildInfoPluginFuncTest
1 parent 0404c07 commit a78f1f0

File tree

1 file changed

+16
-22
lines changed

1 file changed

+16
-22
lines changed

build-tools/src/integTest/groovy/org/elasticsearch/gradle/test/TestBuildInfoPluginFuncTest.groovy

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,6 @@ class TestBuildInfoPluginFuncTest extends AbstractGradleFuncTest {
3939
}
4040
"""
4141

42-
when:
43-
def result = gradleRunner('generateTestBuildInfo').build()
44-
def task = result.task(":generateTestBuildInfo")
45-
46-
47-
then:
48-
task.outcome == TaskOutcome.SUCCESS
49-
50-
def output = file("build/generated-build-info/plugin-test-build-info.json")
51-
output.exists() == true
52-
5342
def location = Map.of(
5443
"module", "com.example",
5544
"representative_class", "com/example/Example.class"
@@ -58,6 +47,15 @@ class TestBuildInfoPluginFuncTest extends AbstractGradleFuncTest {
5847
"component", "example-component",
5948
"locations", List.of(location)
6049
)
50+
51+
def output = file("build/generated-build-info/plugin-test-build-info.json")
52+
53+
when:
54+
def result = gradleRunner('generateTestBuildInfo').build()
55+
56+
then:
57+
result.task(":generateTestBuildInfo").outcome == TaskOutcome.SUCCESS
58+
output.exists() == true
6159
new ObjectMapper().readValue(output, Map.class) == expectedOutput
6260
}
6361

@@ -87,16 +85,7 @@ class TestBuildInfoPluginFuncTest extends AbstractGradleFuncTest {
8785
}
8886
"""
8987

90-
when:
91-
def result = gradleRunner('generateTestBuildInfo').build()
92-
def task = result.task(":generateTestBuildInfo")
93-
94-
95-
then:
96-
task.outcome == TaskOutcome.SUCCESS
97-
9888
def output = file("build/generated-build-info/plugin-test-build-info.json")
99-
output.exists() == true
10089

10190
def locationFromModuleInfo = Map.of(
10291
"module", "org.objectweb.asm",
@@ -115,7 +104,12 @@ class TestBuildInfoPluginFuncTest extends AbstractGradleFuncTest {
115104
"locations", List.of(locationFromModuleInfo, locationFromManifest, locationFromJarFileName)
116105
)
117106

118-
def value = new ObjectMapper().readValue(output, Map.class)
119-
value == expectedOutput
107+
when:
108+
def result = gradleRunner('generateTestBuildInfo').build()
109+
110+
then:
111+
result.task(":generateTestBuildInfo").outcome == TaskOutcome.SUCCESS
112+
output.exists() == true
113+
new ObjectMapper().readValue(output, Map.class) == expectedOutput
120114
}
121115
}

0 commit comments

Comments
 (0)