Skip to content

Commit

Permalink
Fix erroneous addition of useJUnitPlatform() call to sourceSet's test…
Browse files Browse the repository at this point in the history
… dsl
  • Loading branch information
sambsnyd committed Mar 20, 2024
1 parent 02c06d0 commit 74ce09f
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,10 @@ public J.MethodInvocation visitMethodInvocation(J.MethodInvocation method, Execu
if (!(m.getArguments().size() == 1 && m.getArguments().get(0) instanceof J.Lambda)) {
return m;
}
// Other DSLs may be named "test" so only assume it is test {} if it isn't enclosed in anything else
if(getCursor().getParentTreeCursor().firstEnclosing(J.MethodInvocation.class) != null) {
return m;
}
break;
case "named":
if (m.getArguments().isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,4 +202,40 @@ void tasksNamedTestNoType() {
)
);
}

@Test
void leaveOtherTestDslAlone() {
rewriteRun(
//language=groovy
buildGradle(
"""
plugins {
id 'java'
}
sourceSets {
test {
java {
srcDir 'src/test/java'
}
}
}
""",
"""
plugins {
id 'java'
}
sourceSets {
test {
java {
srcDir 'src/test/java'
}
}
}
tasks.withType(Test).configureEach {
useJUnitPlatform()
}
"""
)
);
}
}

0 comments on commit 74ce09f

Please sign in to comment.