Skip to content

Commit 304316a

Browse files
authored
Print output when the name checker IT fails (#31660)
1 parent 3fce13f commit 304316a

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

buildSrc/src/test/java/org/elasticsearch/gradle/precommit/NamingConventionsTaskIT.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ public void testPluginCanBeApplied() {
1717
.build();
1818

1919
assertEquals(TaskOutcome.SUCCESS, result.task(":hello").getOutcome());
20-
assertTrue(result.getOutput().contains("build plugin can be applied"));
20+
String output = result.getOutput();
21+
assertTrue(output, output.contains("build plugin can be applied"));
2122
}
2223

2324
public void testNameCheckFailsAsItShould() {
@@ -29,6 +30,7 @@ public void testNameCheckFailsAsItShould() {
2930

3031
assertNotNull("task did not run", result.task(":namingConventions"));
3132
assertEquals(TaskOutcome.FAILED, result.task(":namingConventions").getOutcome());
33+
String output = result.getOutput();
3234
for (String line : Arrays.asList(
3335
"Found inner classes that are tests, which are excluded from the test runner:",
3436
"* org.elasticsearch.test.NamingConventionsCheckInMainIT$InternalInvalidTests",
@@ -38,8 +40,8 @@ public void testNameCheckFailsAsItShould() {
3840
"Not all subclasses of UnitTestCase match the naming convention. Concrete classes must end with [Tests]:",
3941
"* org.elasticsearch.test.WrongName")) {
4042
assertTrue(
41-
"expected: '" + line + "' but it was not found in the output",
42-
result.getOutput().contains(line)
43+
"expected: '" + line + "' but it was not found in the output:\n" + output,
44+
output.contains(line)
4345
);
4446
}
4547
}
@@ -54,6 +56,7 @@ public void testNameCheckFailsAsItShouldWithMain() {
5456
assertNotNull("task did not run", result.task(":namingConventions"));
5557
assertEquals(TaskOutcome.FAILED, result.task(":namingConventions").getOutcome());
5658

59+
String output = result.getOutput();
5760
for (String line : Arrays.asList(
5861
"Classes ending with [Tests] or [IT] or extending [UnitTestCase] must be in src/test/java:",
5962
"* org.elasticsearch.test.NamingConventionsCheckBadClasses$DummyInterfaceTests",
@@ -63,8 +66,8 @@ public void testNameCheckFailsAsItShouldWithMain() {
6366
"* org.elasticsearch.test.NamingConventionsCheckBadClasses$WrongNameTheSecond",
6467
"* org.elasticsearch.test.NamingConventionsCheckBadClasses$WrongName")) {
6568
assertTrue(
66-
"expected: '" + line + "' but it was not found in the output",
67-
result.getOutput().contains(line)
69+
"expected: '" + line + "' but it was not found in the output:\n"+output,
70+
output.contains(line)
6871
);
6972
}
7073
}

0 commit comments

Comments
 (0)