mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
generate missed tests: add failure notification, detect test framework by config methods (IDEA-140631)
This commit is contained in:
+7
-4
@@ -79,7 +79,7 @@ public class GenerateMissedTestsAction extends PsiElementBaseIntentionAction {
|
||||
}
|
||||
|
||||
if (testClasses.size() == 1) {
|
||||
generateMissedTests((PsiClass)testClasses.get(0), srcClass);
|
||||
generateMissedTests((PsiClass)testClasses.get(0), srcClass, editor);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -89,20 +89,20 @@ public class GenerateMissedTestsAction extends PsiElementBaseIntentionAction {
|
||||
.setItemChoosenCallback(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
generateMissedTests((PsiClass)list.getSelectedValue(), srcClass);
|
||||
generateMissedTests((PsiClass)list.getSelectedValue(), srcClass, editor);
|
||||
}
|
||||
})
|
||||
.setTitle("Choose Test")
|
||||
.createPopup().showInBestPositionFor(editor);
|
||||
}
|
||||
|
||||
private static void generateMissedTests(final PsiClass testClass, PsiClass srcClass) {
|
||||
private static void generateMissedTests(final PsiClass testClass, PsiClass srcClass, Editor srcEditor) {
|
||||
if (testClass != null) {
|
||||
if (!FileModificationService.getInstance().preparePsiElementsForWrite(testClass)) return;
|
||||
final TestFramework framework = TestFrameworks.detectFramework(testClass);
|
||||
if (framework != null) {
|
||||
final Project project = testClass.getProject();
|
||||
final Editor editor = CodeInsightUtil.positionCursor(project, testClass.getContainingFile(), testClass.getLBrace());
|
||||
if (!FileModificationService.getInstance().preparePsiElementsForWrite(testClass)) return;
|
||||
final MissedTestsDialog dialog = new MissedTestsDialog(project, srcClass, testClass, framework);
|
||||
if (dialog.showAndGet()) {
|
||||
WriteCommandAction.runWriteCommandAction(project, new Runnable() {
|
||||
@@ -113,6 +113,9 @@ public class GenerateMissedTestsAction extends PsiElementBaseIntentionAction {
|
||||
});
|
||||
}
|
||||
}
|
||||
else {
|
||||
HintManager.getInstance().showErrorHint(srcEditor, "Failed to detect test framework for " + testClass.getQualifiedName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -57,6 +57,13 @@ public abstract class TestFrameworks {
|
||||
return framework;
|
||||
}
|
||||
}
|
||||
|
||||
for (TestFramework framework : Extensions.getExtensions(TestFramework.EXTENSION_NAME)) {
|
||||
if (framework.findSetUpMethod(psiClass) != null || framework.findTearDownMethod(psiClass) != null) {
|
||||
return framework;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user