mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
junit 5: erasure type parameters for test signatures
This commit is contained in:
@@ -44,6 +44,7 @@ import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.psi.util.ClassUtil;
|
||||
import com.intellij.psi.util.TypeConversionUtil;
|
||||
import com.intellij.refactoring.listeners.RefactoringElementListener;
|
||||
import com.intellij.rt.execution.junit.JUnitStarter;
|
||||
import com.intellij.rt.execution.junit.RepeatCount;
|
||||
@@ -660,8 +661,11 @@ public class JUnitConfiguration extends JavaTestConfigurationBase {
|
||||
|
||||
public static String getMethodPresentation(PsiMethod method) {
|
||||
if (method.getParameterList().getParametersCount() > 0 && MetaAnnotationUtil.isMetaAnnotated(method, JUnitUtil.TEST5_ANNOTATIONS)) {
|
||||
return method.getName() + "(" + StringUtil.join(method.getParameterList().getParameters(),
|
||||
param -> param.getType().accept(createSignatureVisitor()),
|
||||
return method.getName() + "(" + StringUtil.join(method.getParameterList().getParameters(),
|
||||
param -> {
|
||||
PsiType type = TypeConversionUtil.erasure(param.getType());
|
||||
return type != null ? type.accept(createSignatureVisitor()) : "";
|
||||
},
|
||||
",") + ")";
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -78,15 +78,16 @@ class JUnit5AcceptanceTest extends JUnit5CodeInsightTest {
|
||||
void methodPresentations() {
|
||||
doTest(() -> {
|
||||
myFixture.addClass("package a; public class TestInfo {}");
|
||||
PsiClass aClass = myFixture.addClass("class MyTest {" +
|
||||
PsiClass aClass = myFixture.addClass("class MyTest<T extends a.TestInfo> {" +
|
||||
" @org.junit.jupiter.api.Test void method() {}" +
|
||||
" @org.junit.jupiter.api.Test void method(a.TestInfo info) {}" +
|
||||
" @org.junit.jupiter.api.Test void method(T info) {}" +
|
||||
" @org.junit.Test void method1() {}" +
|
||||
" @org.junit.Test void method1(a.TestInfo info) {}" +
|
||||
"}");
|
||||
assertNotNull(aClass);
|
||||
|
||||
Stream<String> expectedData = Arrays.stream(new String[]{"method", "method(a.TestInfo)", "method1", "method1"});
|
||||
Stream<String> expectedData = Arrays.stream(new String[]{"method", "method(a.TestInfo)", "method(a.TestInfo)", "method1", "method1"});
|
||||
StreamEx.of(aClass.getMethods())
|
||||
.zipWith(expectedData)
|
||||
.forEach(e -> assertEquals(e.getValue(), JUnitConfiguration.Data.getMethodPresentation(e.getKey())));
|
||||
|
||||
Reference in New Issue
Block a user