mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
+6
@@ -30,6 +30,7 @@ import com.intellij.execution.configurations.RunConfiguration;
|
||||
import com.intellij.execution.testframework.sm.runner.SMTRunnerConsoleProperties;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.tree.TreeSelectionModel;
|
||||
import java.util.Collection;
|
||||
|
||||
public abstract class JavaAwareTestConsoleProperties<T extends ModuleBasedConfiguration<JavaRunConfigurationModule> & CommonJavaRunConfigurationParameters> extends SMTRunnerConsoleProperties {
|
||||
@@ -48,6 +49,11 @@ public abstract class JavaAwareTestConsoleProperties<T extends ModuleBasedConfig
|
||||
return (T)super.getConfiguration();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getSelectionMode() {
|
||||
return TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean fixEmptySuite() {
|
||||
return ResetConfigurationModuleAdapter.tryWithAnotherModule(getConfiguration(), isDebug());
|
||||
|
||||
@@ -82,7 +82,7 @@ public class ImportModuleAction extends AnAction {
|
||||
}
|
||||
|
||||
public static List<Module> createFromWizard(@Nullable Project project, AbstractProjectWizard wizard) {
|
||||
if (project == null && wizard.getStepCount() > 0) {
|
||||
if (project == null) {
|
||||
Project newProject = NewProjectUtil.createFromWizard(wizard, null);
|
||||
return newProject == null ? Collections.<Module>emptyList() : Arrays.asList(ModuleManager.getInstance(newProject).getModules());
|
||||
}
|
||||
@@ -94,7 +94,6 @@ public class ImportModuleAction extends AnAction {
|
||||
return Collections.singletonList(module);
|
||||
}
|
||||
else {
|
||||
assert project != null;
|
||||
return projectBuilder.commit(project);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,8 +136,9 @@ public class ConfigurationsTest extends BaseConfigurationTestCase {
|
||||
JUnitConfiguration configuration = createConfiguration(testA);
|
||||
JavaParameters parameters = checkCanRun(configuration);
|
||||
CHECK.empty(parameters.getVMParametersList().getList());
|
||||
final SegmentedOutputStream notifications = new SegmentedOutputStream(System.out);
|
||||
assertTrue(JUnitStarter.checkVersion(parameters.getProgramParametersList().getArray(),
|
||||
new SegmentedOutputStream(System.out)));
|
||||
new PrintStream(notifications)));
|
||||
assertTrue(parameters.getProgramParametersList().getList().contains(testA.getQualifiedName()));
|
||||
assertEquals(JUnitStarter.class.getName(), parameters.getMainClass());
|
||||
assertEquals(myJdk.getHomeDirectory().getPresentableUrl(), parameters.getJdkPath());
|
||||
|
||||
+7
@@ -37,9 +37,11 @@ import com.intellij.util.config.ToggleBooleanProperty;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.xdebugger.XDebugSession;
|
||||
import com.intellij.xdebugger.XDebuggerManager;
|
||||
import org.intellij.lang.annotations.JdkConstants;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.tree.TreeSelectionModel;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -195,4 +197,9 @@ public abstract class TestConsoleProperties extends StoringPropertyContainer imp
|
||||
Icon icon = AllIcons.RunConfigurations.IncludeNonStartedTests_Rerun;
|
||||
return new ToggleBooleanProperty(text, null, icon, this, INCLUDE_NON_STARTED_IN_RERUN_FAILED);
|
||||
}
|
||||
|
||||
@JdkConstants.TreeSelectionMode
|
||||
protected int getSelectionMode() {
|
||||
return TreeSelectionModel.SINGLE_TREE_SELECTION;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
package com.intellij.execution.testframework;
|
||||
|
||||
import com.intellij.execution.Location;
|
||||
import com.intellij.execution.testframework.actions.ViewAssertEqualsDiffAction;
|
||||
import com.intellij.ide.CopyProvider;
|
||||
import com.intellij.ide.actions.CopyReferenceAction;
|
||||
import com.intellij.openapi.Disposable;
|
||||
@@ -35,12 +34,14 @@ import com.intellij.ui.treeStructure.Tree;
|
||||
import com.intellij.util.EditSourceOnDoubleClickHandler;
|
||||
import com.intellij.util.containers.Convertor;
|
||||
import com.intellij.util.ui.tree.TreeUtil;
|
||||
import org.intellij.lang.annotations.JdkConstants;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.plaf.TreeUI;
|
||||
import javax.swing.tree.*;
|
||||
import javax.swing.tree.DefaultMutableTreeNode;
|
||||
import javax.swing.tree.DefaultTreeModel;
|
||||
import javax.swing.tree.TreeCellRenderer;
|
||||
import javax.swing.tree.TreePath;
|
||||
import java.awt.datatransfer.StringSelection;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -68,7 +69,7 @@ public abstract class TestTreeView extends Tree implements DataProvider, CopyPro
|
||||
|
||||
public void attachToModel(final TestFrameworkRunningModel model) {
|
||||
setModel(new DefaultTreeModel(new DefaultMutableTreeNode(model.getRoot())));
|
||||
getSelectionModel().setSelectionMode(getSelectionMode());
|
||||
getSelectionModel().setSelectionMode(model.getProperties().getSelectionMode());
|
||||
myModel = model;
|
||||
Disposer.register(myModel, myModel.getRoot());
|
||||
Disposer.register(myModel, new Disposable() {
|
||||
@@ -169,9 +170,4 @@ public abstract class TestTreeView extends Tree implements DataProvider, CopyPro
|
||||
TreeUtil.installActions(this);
|
||||
PopupHandler.installPopupHandler(this, IdeActions.GROUP_TESTTREE_POPUP, ActionPlaces.TESTTREE_VIEW_POPUP);
|
||||
}
|
||||
|
||||
@JdkConstants.TreeSelectionMode
|
||||
protected int getSelectionMode() {
|
||||
return TreeSelectionModel.SINGLE_TREE_SELECTION;
|
||||
}
|
||||
}
|
||||
@@ -48,7 +48,7 @@ public class LineEndingsManager extends FileDocumentManagerAdapter {
|
||||
@Override
|
||||
public void run() {
|
||||
IdeFrame frame = WindowManager.getInstance().getIdeFrame(myProject);
|
||||
StatusBar statusBar = frame.getStatusBar();
|
||||
StatusBar statusBar = frame != null ? frame.getStatusBar() : null;
|
||||
StatusBarWidget widget = statusBar != null ? statusBar.getWidget("LineSeparator") : null;
|
||||
|
||||
if (widget instanceof LineSeparatorPanel) {
|
||||
|
||||
@@ -22,7 +22,6 @@ import com.intellij.execution.testframework.TestTreeView;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.tree.TreePath;
|
||||
import javax.swing.tree.TreeSelectionModel;
|
||||
|
||||
public class JUnitTestTreeView extends TestTreeView {
|
||||
|
||||
@@ -42,9 +41,4 @@ public class JUnitTestTreeView extends TestTreeView {
|
||||
final boolean hasFocus) {
|
||||
return Formatters.printTest(TestProxyClient.from(value));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getSelectionMode() {
|
||||
return TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,15 +17,14 @@ package com.intellij.junit3;
|
||||
|
||||
import com.intellij.rt.execution.junit.*;
|
||||
import com.intellij.rt.execution.junit.segments.OutputObjectRegistry;
|
||||
import com.intellij.rt.execution.junit.segments.SegmentedOutputStream;
|
||||
import com.intellij.rt.execution.junit.segments.PacketProcessor;
|
||||
import jetbrains.buildServer.messages.serviceMessages.ServiceMessage;
|
||||
import jetbrains.buildServer.messages.serviceMessages.ServiceMessageTypes;
|
||||
import junit.framework.*;
|
||||
import junit.textui.ResultPrinter;
|
||||
import junit.textui.TestRunner;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Enumeration;
|
||||
import java.util.List;
|
||||
import java.util.Vector;
|
||||
import java.util.*;
|
||||
|
||||
public class JUnit3IdeaTestRunner extends TestRunner implements IdeaTestRunner {
|
||||
private TestListener myTestsListener;
|
||||
@@ -39,7 +38,7 @@ public class JUnit3IdeaTestRunner extends TestRunner implements IdeaTestRunner {
|
||||
|
||||
public int startRunnerWithArgs(String[] args, ArrayList listeners, String name, int count, boolean sendTree) {
|
||||
myListeners = listeners;
|
||||
mySendTree = sendTree;
|
||||
mySendTree = sendTree && !(myTestsListener instanceof SMTestListener);
|
||||
if (sendTree) {
|
||||
setPrinter(new TimeSender(myRegistry));
|
||||
}
|
||||
@@ -69,9 +68,13 @@ public class JUnit3IdeaTestRunner extends TestRunner implements IdeaTestRunner {
|
||||
super.runFailed(message);
|
||||
}
|
||||
|
||||
public void setStreams(SegmentedOutputStream segmentedOut, SegmentedOutputStream segmentedErr, int lastIdx) {
|
||||
myRegistry = new JUnit3OutputObjectRegistry(segmentedOut, lastIdx);
|
||||
myTestsListener = new TestResultsSender(myRegistry);
|
||||
public void setStreams(Object segmentedOut, Object segmentedErr, int lastIdx) {
|
||||
if (JUnitStarter.SM_RUNNER) {
|
||||
myTestsListener = new SMTestListener();
|
||||
} else {
|
||||
myRegistry = new JUnit3OutputObjectRegistry((PacketProcessor)segmentedOut, lastIdx);
|
||||
myTestsListener = new TestResultsSender(myRegistry);
|
||||
}
|
||||
}
|
||||
|
||||
public Object getTestToStart(String[] args, String name) {
|
||||
@@ -138,7 +141,11 @@ public class JUnit3IdeaTestRunner extends TestRunner implements IdeaTestRunner {
|
||||
System.err.println("Internal Error occured.");
|
||||
e.printStackTrace(System.err);
|
||||
}
|
||||
return super.doRun(suite, wait);
|
||||
final TestResult testResult = super.doRun(suite, wait);
|
||||
if (myTestsListener instanceof SMTestListener) {
|
||||
((SMTestListener)myTestsListener).finishSuite();
|
||||
}
|
||||
return testResult;
|
||||
}
|
||||
|
||||
static Vector getTestCasesOf(Test test) {
|
||||
@@ -163,4 +170,53 @@ public class JUnit3IdeaTestRunner extends TestRunner implements IdeaTestRunner {
|
||||
super(DeafStream.DEAF_PRINT_STREAM);
|
||||
}
|
||||
}
|
||||
|
||||
private static class SMTestListener implements TestListener {
|
||||
private String myClassName;
|
||||
|
||||
public void addError(Test test, Throwable e) {
|
||||
final String failureMessage = e.getMessage();
|
||||
final Map attrs = new HashMap();
|
||||
attrs.put("name", getMethodName(test));
|
||||
attrs.put("message", failureMessage != null ? failureMessage : "");
|
||||
System.out.println(ServiceMessage.asString(ServiceMessageTypes.TEST_FAILED, attrs));
|
||||
}
|
||||
|
||||
private static String getMethodName(Test test) {
|
||||
final String toString = test.toString();
|
||||
final int braceIdx = toString.indexOf("(");
|
||||
return braceIdx > 0 ? toString.substring(0, braceIdx) : toString;
|
||||
}
|
||||
|
||||
private static String getClassName(Test test) {
|
||||
final String toString = test.toString();
|
||||
final int braceIdx = toString.indexOf("(");
|
||||
return braceIdx > 0 && toString.endsWith(")") ? toString.substring(braceIdx + 1, toString.length() - 1) : null;
|
||||
}
|
||||
|
||||
public void addFailure(Test test, AssertionFailedError e) {
|
||||
addError(test, e);
|
||||
}
|
||||
|
||||
public void endTest(Test test) {
|
||||
System.out.println("\n##teamcity[testFinished name=\'" + getMethodName(test) + "\']");
|
||||
}
|
||||
|
||||
public void startTest(Test test) {
|
||||
final String className = getClassName(test);
|
||||
if (className != null && !className.equals(myClassName)) {
|
||||
finishSuite();
|
||||
myClassName = className;
|
||||
System.out.println("##teamcity[testSuiteStarted name =\'" + myClassName + "\' locationHint=\'java:suite://" + className + "\']");
|
||||
}
|
||||
final String methodName = getMethodName(test);
|
||||
System.out.println("##teamcity[testStarted name=\'" + methodName + "\' locationHint=\'java:test://" + className + "." + methodName + "\']");
|
||||
}
|
||||
|
||||
protected void finishSuite() {
|
||||
if (myClassName != null) {
|
||||
System.out.println("##teamcity[testSuiteFinished name=\'" + myClassName + "\']");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,8 +17,7 @@ package com.intellij.junit4;
|
||||
|
||||
import com.intellij.rt.execution.junit.*;
|
||||
import com.intellij.rt.execution.junit.segments.OutputObjectRegistry;
|
||||
import com.intellij.rt.execution.junit.segments.Packet;
|
||||
import com.intellij.rt.execution.junit.segments.SegmentedOutputStream;
|
||||
import com.intellij.rt.execution.junit.segments.PacketProcessor;
|
||||
import org.junit.internal.requests.ClassRequest;
|
||||
import org.junit.internal.requests.FilterRequest;
|
||||
import org.junit.runner.*;
|
||||
@@ -183,11 +182,11 @@ public class JUnit4IdeaTestRunner implements IdeaTestRunner {
|
||||
}
|
||||
|
||||
|
||||
public void setStreams(SegmentedOutputStream segmentedOut, SegmentedOutputStream segmentedErr, int lastIdx) {
|
||||
public void setStreams(Object segmentedOut, Object segmentedErr, int lastIdx) {
|
||||
if (JUnitStarter.SM_RUNNER) {
|
||||
myTestsListener = new SMTestSender();
|
||||
} else {
|
||||
myRegistry = new JUnit4OutputObjectRegistry(segmentedOut, lastIdx);
|
||||
myRegistry = new JUnit4OutputObjectRegistry((PacketProcessor)segmentedOut, lastIdx);
|
||||
myTestsListener = new JUnit4TestResultsSender(myRegistry);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,15 +46,15 @@ class SMTestSender extends RunListener {
|
||||
|
||||
public void testRunStarted(Description description) throws Exception {
|
||||
myCurrentClassName = myIgnoreTopSuite ? description.toString() : null;
|
||||
System.out.println("##teamcity[enteredTheMatrix]");
|
||||
System.out.println("##teamcity[enteredTheMatrix]\n");
|
||||
}
|
||||
|
||||
public void testRunFinished(Result result) throws Exception {
|
||||
if (myParamName != null) {
|
||||
System.out.println("##teamcity[testSuiteFinished name=\'" + myParamName + "\']");
|
||||
System.out.println("##teamcity[testSuiteFinished name=\'" + myParamName + "\']\n");
|
||||
}
|
||||
if (myCurrentClassName != null) {
|
||||
System.out.println("##teamcity[testSuiteFinished name=\'" + myCurrentClassName + "\']");
|
||||
System.out.println("##teamcity[testSuiteFinished name=\'" + myCurrentClassName + "\']\n");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ class SMTestSender extends RunListener {
|
||||
}
|
||||
|
||||
public void testFinished(Description description) throws Exception {
|
||||
System.out.println("##teamcity[testFinished name=\'" + JUnit4ReflectionUtil.getMethodName(description) + "\']");
|
||||
System.out.println("\n##teamcity[testFinished name=\'" + JUnit4ReflectionUtil.getMethodName(description) + "\']");
|
||||
}
|
||||
|
||||
public void testFailure(Failure failure) throws Exception {
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
package com.intellij.rt.execution.junit;
|
||||
|
||||
import com.intellij.rt.execution.junit.segments.OutputObjectRegistry;
|
||||
import com.intellij.rt.execution.junit.segments.SegmentedOutputStream;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -29,7 +28,7 @@ import java.util.List;
|
||||
public interface IdeaTestRunner {
|
||||
|
||||
int startRunnerWithArgs(String[] args, ArrayList listeners, String name, int count, boolean sendTree);
|
||||
void setStreams(SegmentedOutputStream segmentedOut, SegmentedOutputStream segmentedErr, int lastIdx);
|
||||
void setStreams(Object segmentedOut, Object segmentedErr, int lastIdx);
|
||||
|
||||
Object getTestToStart(String[] args, String name);
|
||||
List getChildTests(Object description);
|
||||
|
||||
@@ -72,8 +72,8 @@ public class JUnitForkedStarter {
|
||||
String[] args,
|
||||
boolean isJUnit4,
|
||||
List listeners,
|
||||
String params, SegmentedOutputStream out,
|
||||
SegmentedOutputStream err,
|
||||
String params, Object out,
|
||||
Object err,
|
||||
String forkMode,
|
||||
String path) throws Exception {
|
||||
final List parameters = new ArrayList();
|
||||
@@ -178,8 +178,8 @@ public class JUnitForkedStarter {
|
||||
|
||||
private static int processChildren(boolean isJUnit4,
|
||||
List listeners,
|
||||
SegmentedOutputStream out,
|
||||
SegmentedOutputStream err,
|
||||
Object out,
|
||||
Object err,
|
||||
List parameters,
|
||||
IdeaTestRunner testRunner,
|
||||
List children,
|
||||
@@ -206,8 +206,8 @@ public class JUnitForkedStarter {
|
||||
|
||||
private static int runChild(boolean isJUnit4,
|
||||
List listeners,
|
||||
SegmentedOutputStream out,
|
||||
SegmentedOutputStream err,
|
||||
Object out,
|
||||
Object err,
|
||||
List parameters,
|
||||
String description,
|
||||
File workingDir,
|
||||
@@ -265,7 +265,9 @@ public class JUnitForkedStarter {
|
||||
|
||||
final Process exec = builder.createProcess();
|
||||
final int result = exec.waitFor();
|
||||
ForkedVMWrapper.readWrapped(testOutputPath, out.getPrintStream(), err.getPrintStream());
|
||||
ForkedVMWrapper.readWrapped(testOutputPath,
|
||||
JUnitStarter.SM_RUNNER ? ((PrintStream)out) : ((SegmentedOutputStream)out).getPrintStream(),
|
||||
JUnitStarter.SM_RUNNER ? ((PrintStream)err) : ((SegmentedOutputStream)err).getPrintStream());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,8 +51,6 @@ public class JUnitStarter {
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
SegmentedOutputStream out = new SegmentedOutputStream(System.out);
|
||||
SegmentedOutputStream err = new SegmentedOutputStream(System.err);
|
||||
Vector argList = new Vector();
|
||||
for (int i = 0; i < args.length; i++) {
|
||||
String arg = args[i];
|
||||
@@ -64,18 +62,16 @@ public class JUnitStarter {
|
||||
|
||||
boolean isJUnit4 = processParameters(argList, listeners, name);
|
||||
|
||||
if (!canWorkWithJUnitVersion(err, isJUnit4)) {
|
||||
err.flush();
|
||||
if (!canWorkWithJUnitVersion(System.err, isJUnit4)) {
|
||||
System.exit(-3);
|
||||
}
|
||||
if (!checkVersion(args, err)) {
|
||||
err.flush();
|
||||
if (!checkVersion(args, System.err)) {
|
||||
System.exit(-3);
|
||||
}
|
||||
|
||||
String[] array = new String[argList.size()];
|
||||
argList.copyInto(array);
|
||||
int exitCode = prepareStreamsAndStart(array, isJUnit4, listeners, name[0], out, err);
|
||||
int exitCode = prepareStreamsAndStart(array, isJUnit4, listeners, name[0]);
|
||||
System.exit(exitCode);
|
||||
}
|
||||
|
||||
@@ -171,15 +167,14 @@ public class JUnitStarter {
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean checkVersion(String[] args, SegmentedOutputStream notifications) {
|
||||
public static boolean checkVersion(String[] args, PrintStream printStream) {
|
||||
for (int i = 0; i < args.length; i++) {
|
||||
String arg = args[i];
|
||||
if (arg.startsWith(IDE_VERSION)) {
|
||||
int ideVersion = Integer.parseInt(arg.substring(IDE_VERSION.length(), arg.length()));
|
||||
if (ideVersion != VERSION) {
|
||||
PrintStream stream = new PrintStream(notifications);
|
||||
stream.println("Wrong agent version: " + VERSION + ". IDE expects version: " + ideVersion);
|
||||
stream.flush();
|
||||
printStream.println("Wrong agent version: " + VERSION + ". IDE expects version: " + ideVersion);
|
||||
printStream.flush();
|
||||
return false;
|
||||
} else
|
||||
return true;
|
||||
@@ -188,18 +183,17 @@ public class JUnitStarter {
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean canWorkWithJUnitVersion(OutputStream notifications, boolean isJUnit4) {
|
||||
final PrintStream stream = new PrintStream(notifications);
|
||||
private static boolean canWorkWithJUnitVersion(PrintStream printStream, boolean isJUnit4) {
|
||||
try {
|
||||
junitVersionChecks(isJUnit4);
|
||||
} catch (Throwable e) {
|
||||
stream.println("!!! JUnit version 3.8 or later expected:");
|
||||
stream.println();
|
||||
e.printStackTrace(stream);
|
||||
stream.flush();
|
||||
printStream.println("!!! JUnit version 3.8 or later expected:");
|
||||
printStream.println();
|
||||
e.printStackTrace(printStream);
|
||||
printStream.flush();
|
||||
return false;
|
||||
} finally {
|
||||
stream.flush();
|
||||
printStream.flush();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -214,20 +208,22 @@ public class JUnitStarter {
|
||||
private static int prepareStreamsAndStart(String[] args,
|
||||
final boolean isJUnit4,
|
||||
ArrayList listeners,
|
||||
String name,
|
||||
SegmentedOutputStream out,
|
||||
SegmentedOutputStream err) {
|
||||
String name) {
|
||||
PrintStream oldOut = System.out;
|
||||
PrintStream oldErr = System.err;
|
||||
try {
|
||||
System.setOut(new PrintStream(out));
|
||||
System.setErr(new PrintStream(err));
|
||||
IdeaTestRunner testRunner = (IdeaTestRunner)getAgentClass(isJUnit4).newInstance();
|
||||
Object out = SM_RUNNER ? System.out : (Object)new SegmentedOutputStream(System.out);
|
||||
Object err = SM_RUNNER ? System.err : (Object)new SegmentedOutputStream(System.err);
|
||||
if (!SM_RUNNER) {
|
||||
System.setOut(new PrintStream((OutputStream)out));
|
||||
System.setErr(new PrintStream((OutputStream)err));
|
||||
}
|
||||
if (ourCommandFileName != null) {
|
||||
if (!"none".equals(ourForkMode) || ourWorkingDirs != null && new File(ourWorkingDirs).length() > 0) {
|
||||
return JUnitForkedStarter.startForkedVMs(ourWorkingDirs, args, isJUnit4, listeners, name, out, err, ourForkMode, ourCommandFileName);
|
||||
}
|
||||
}
|
||||
IdeaTestRunner testRunner = (IdeaTestRunner)getAgentClass(isJUnit4).newInstance();
|
||||
testRunner.setStreams(out, err, 0);
|
||||
return testRunner.startRunnerWithArgs(args, listeners, name, ourCount, !SM_RUNNER);
|
||||
}
|
||||
|
||||
+75
-34
@@ -40,7 +40,6 @@ import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.psi.search.PackageScope;
|
||||
import com.intellij.psi.search.searches.AnnotatedMembersSearch;
|
||||
import com.intellij.psi.util.ClassUtil;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.theoryinpractice.testng.model.IDEARemoteTestRunnerClient;
|
||||
import com.theoryinpractice.testng.model.TestClassFilter;
|
||||
import com.theoryinpractice.testng.model.TestData;
|
||||
@@ -48,10 +47,7 @@ import com.theoryinpractice.testng.model.TestType;
|
||||
import com.theoryinpractice.testng.util.TestNGUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.testng.xml.LaunchSuite;
|
||||
import org.testng.xml.Parser;
|
||||
import org.testng.xml.SuiteGenerator;
|
||||
import org.testng.xml.XmlSuite;
|
||||
import org.testng.xml.*;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.ServerSocket;
|
||||
@@ -61,7 +57,7 @@ import java.util.regex.PatternSyntaxException;
|
||||
|
||||
public class SearchingForTestsTask extends SearchForTestsTask {
|
||||
private static final Logger LOG = Logger.getInstance("#" + SearchingForTestsTask.class.getName());
|
||||
private final Map<PsiClass, Collection<PsiMethod>> myClasses;
|
||||
private final Map<PsiClass, Map<PsiMethod, List<String>>> myClasses;
|
||||
private final TestData myData;
|
||||
private final Project myProject;
|
||||
private final TestNGConfiguration myConfig;
|
||||
@@ -78,7 +74,7 @@ public class SearchingForTestsTask extends SearchForTestsTask {
|
||||
myProject = config.getProject();
|
||||
myConfig = config;
|
||||
myTempFile = tempFile;
|
||||
myClasses = new LinkedHashMap<PsiClass, Collection<PsiMethod>>();
|
||||
myClasses = new LinkedHashMap<PsiClass, Map<PsiMethod, List<String>>>();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -126,20 +122,20 @@ public class SearchingForTestsTask extends SearchForTestsTask {
|
||||
}
|
||||
|
||||
private void composeTestSuiteFromClasses() {
|
||||
Map<String, Collection<String>> map = new LinkedHashMap<String, Collection<String>>();
|
||||
Map<String, Map<String, List<String>>> map = new LinkedHashMap<String, Map<String, List<String>>>();
|
||||
|
||||
final boolean findTestMethodsForClass = shouldSearchForTestMethods();
|
||||
|
||||
for (final Map.Entry<PsiClass, Collection<PsiMethod>> entry : myClasses.entrySet()) {
|
||||
final Collection<PsiMethod> depMethods = entry.getValue();
|
||||
Collection<String> methods = new LinkedHashSet<String>(depMethods.size());
|
||||
for (PsiMethod method : depMethods) {
|
||||
methods.add(method.getName());
|
||||
for (final Map.Entry<PsiClass, Map<PsiMethod, List<String>>> entry : myClasses.entrySet()) {
|
||||
final Map<PsiMethod, List<String>> depMethods = entry.getValue();
|
||||
LinkedHashMap<String, List<String>> methods = new LinkedHashMap<String, List<String>>();
|
||||
for (Map.Entry<PsiMethod, List<String>> method : depMethods.entrySet()) {
|
||||
methods.put(method.getKey().getName(), method.getValue());
|
||||
}
|
||||
if (findTestMethodsForClass && depMethods.isEmpty()) {
|
||||
for (PsiMethod method : entry.getKey().getMethods()) {
|
||||
if (TestNGUtil.hasTest(method)) {
|
||||
methods.add(method.getName());
|
||||
methods.put(method.getName(), Collections.<String>emptyList());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -180,10 +176,53 @@ public class SearchingForTestsTask extends SearchForTestsTask {
|
||||
logLevel = 1;
|
||||
}
|
||||
|
||||
LaunchSuite suite =
|
||||
SuiteGenerator.createSuite(myProject.getName(), null, map, groupNames, testParams, "jdk", logLevel);
|
||||
|
||||
File xmlFile = suite.save(new File(PathManager.getSystemPath()));
|
||||
File xmlFile;
|
||||
if (groupNames != null) {
|
||||
final LinkedHashMap<String, Collection<String>> methodNames = new LinkedHashMap<String, Collection<String>>();
|
||||
for (Map.Entry<String, Map<String, List<String>>> entry : map.entrySet()) {
|
||||
methodNames.put(entry.getKey(), entry.getValue().keySet());
|
||||
}
|
||||
LaunchSuite suite =
|
||||
SuiteGenerator.createSuite(myProject.getName(), null, methodNames, groupNames, testParams, "jdk", logLevel);
|
||||
xmlFile = suite.save(new File(PathManager.getSystemPath()));
|
||||
}
|
||||
else {
|
||||
final XmlSuite xmlSuite = new XmlSuite();
|
||||
XmlTest xmlTest = new XmlTest(xmlSuite);
|
||||
xmlTest.setName(myProject.getName());
|
||||
xmlTest.setParameters(testParams);
|
||||
List<XmlClass> xmlClasses = new ArrayList<XmlClass>();
|
||||
int idx = 0;
|
||||
for (String className : map.keySet()) {
|
||||
final XmlClass xmlClass = new XmlClass(className, idx++, false);
|
||||
final ArrayList<XmlInclude> includedMethods = new ArrayList<XmlInclude>();
|
||||
final Map<String, List<String>> collection = map.get(className);
|
||||
int mIdx = 0;
|
||||
for (String methodName : collection.keySet()) {
|
||||
final List<Integer> includes = new ArrayList<Integer>();
|
||||
for (String include : collection.get(methodName)) {
|
||||
try {
|
||||
includes.add(Integer.parseInt(include));
|
||||
}
|
||||
catch (NumberFormatException e) {
|
||||
LOG.error(e);
|
||||
}
|
||||
}
|
||||
includedMethods.add(new XmlInclude(methodName, includes, mIdx++));
|
||||
}
|
||||
xmlClass.setIncludedMethods(includedMethods);
|
||||
xmlClasses.add(xmlClass);
|
||||
}
|
||||
xmlTest.setXmlClasses(xmlClasses);
|
||||
xmlFile = new File(PathManager.getSystemPath(), "temp-testng-customsuite.xml");
|
||||
final String toXml = xmlSuite.toXml();
|
||||
try {
|
||||
FileUtil.writeToFile(xmlFile, toXml);
|
||||
}
|
||||
catch (IOException e) {
|
||||
LOG.error(e);
|
||||
}
|
||||
}
|
||||
String path = xmlFile.getAbsolutePath() + "\n";
|
||||
try {
|
||||
FileUtil.writeToFile(myTempFile, path.getBytes(CharsetToolkit.UTF8_CHARSET), true);
|
||||
@@ -195,7 +234,7 @@ public class SearchingForTestsTask extends SearchForTestsTask {
|
||||
|
||||
private boolean shouldSearchForTestMethods() {
|
||||
boolean dependantMethods = false;
|
||||
for (Collection<PsiMethod> methods : myClasses.values()) {
|
||||
for (Map<PsiMethod, List<String>> methods : myClasses.values()) {
|
||||
if (!methods.isEmpty()) {
|
||||
dependantMethods = true;
|
||||
break;
|
||||
@@ -239,7 +278,7 @@ public class SearchingForTestsTask extends SearchForTestsTask {
|
||||
}
|
||||
}
|
||||
|
||||
protected void fillTestObjects(final Map<PsiClass, Collection<PsiMethod>> classes)
|
||||
protected void fillTestObjects(final Map<PsiClass, Map<PsiMethod, List<String>>> classes)
|
||||
throws CantRunException {
|
||||
final TestData data = myConfig.getPersistantData();
|
||||
final PsiManager psiManager = PsiManager.getInstance(myProject);
|
||||
@@ -322,7 +361,7 @@ public class SearchingForTestsTask extends SearchForTestsTask {
|
||||
.getAllTestClasses(new TestClassFilter(data.getScope().getSourceScope(myConfig).getGlobalSearchScope(), myProject, true, true), false);
|
||||
if (testClasses != null) {
|
||||
for (PsiClass c : testClasses) {
|
||||
classes.put(c, new HashSet<PsiMethod>());
|
||||
classes.put(c, new LinkedHashMap<PsiMethod, List<String>>());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -401,7 +440,7 @@ public class SearchingForTestsTask extends SearchForTestsTask {
|
||||
}
|
||||
}
|
||||
|
||||
private void collectTestMethods(Map<PsiClass, Collection<PsiMethod>> classes, final PsiClass psiClass, final String methodName) {
|
||||
private void collectTestMethods(Map<PsiClass, Map<PsiMethod, List<String>>> classes, final PsiClass psiClass, final String methodName) {
|
||||
final PsiMethod[] methods = ApplicationManager.getApplication().runReadAction(
|
||||
new Computable<PsiMethod[]>() {
|
||||
public PsiMethod[] compute() {
|
||||
@@ -410,12 +449,14 @@ public class SearchingForTestsTask extends SearchForTestsTask {
|
||||
}
|
||||
);
|
||||
calculateDependencies(methods, classes, psiClass);
|
||||
Collection<PsiMethod> psiMethods = classes.get(psiClass);
|
||||
Map<PsiMethod, List<String>> psiMethods = classes.get(psiClass);
|
||||
if (psiMethods == null) {
|
||||
psiMethods = new LinkedHashSet<PsiMethod>();
|
||||
psiMethods = new LinkedHashMap<PsiMethod, List<String>>();
|
||||
classes.put(psiClass, psiMethods);
|
||||
}
|
||||
ContainerUtil.addAll(psiMethods, methods);
|
||||
for (PsiMethod method : methods) {
|
||||
psiMethods.put(method, Collections.<String>emptyList());
|
||||
}
|
||||
}
|
||||
|
||||
private Map<String, String> buildTestParameters() {
|
||||
@@ -452,13 +493,13 @@ public class SearchingForTestsTask extends SearchForTestsTask {
|
||||
}
|
||||
|
||||
private void calculateDependencies(PsiMethod[] methods,
|
||||
final Map<PsiClass, Collection<PsiMethod>> results,
|
||||
final Map<PsiClass, Map<PsiMethod, List<String>>> results,
|
||||
@Nullable final PsiClass... classes) {
|
||||
calculateDependencies(methods, results, new LinkedHashSet<PsiMember>(), classes);
|
||||
}
|
||||
|
||||
private void calculateDependencies(final PsiMethod[] methods,
|
||||
final Map<PsiClass, Collection<PsiMethod>> results,
|
||||
final Map<PsiClass, Map<PsiMethod, List<String>>> results,
|
||||
final Set<PsiMember> alreadyMarkedToBeChecked,
|
||||
@Nullable final PsiClass... classes) {
|
||||
if (classes != null && classes.length > 0) {
|
||||
@@ -488,7 +529,7 @@ public class SearchingForTestsTask extends SearchForTestsTask {
|
||||
|
||||
if (methods == null) {
|
||||
for (PsiClass c : classes) {
|
||||
results.put(c, new LinkedHashSet<PsiMethod>());
|
||||
results.put(c, new LinkedHashMap<PsiMethod, List<String>>());
|
||||
}
|
||||
} else {
|
||||
for (PsiMember psiMember : membersToCheckNow) {
|
||||
@@ -506,7 +547,7 @@ public class SearchingForTestsTask extends SearchForTestsTask {
|
||||
}
|
||||
}
|
||||
|
||||
private static void collectDependsOnMethods(final Map<PsiClass, Collection<PsiMethod>> results,
|
||||
private static void collectDependsOnMethods(final Map<PsiClass, Map<PsiMethod, List<String>>> results,
|
||||
final Set<PsiMember> alreadyMarkedToBeChecked,
|
||||
final Set<PsiMember> membersToCheckNow,
|
||||
final PsiMethod[] methods,
|
||||
@@ -557,7 +598,7 @@ public class SearchingForTestsTask extends SearchForTestsTask {
|
||||
PsiClass containingClass,
|
||||
Set<PsiMember> alreadyMarkedToBeChecked,
|
||||
Set<PsiMember> membersToCheckNow,
|
||||
Map<PsiClass, Collection<PsiMethod>> results) {
|
||||
Map<PsiClass, Map<PsiMethod, List<String>>> results) {
|
||||
final PsiMethod[] psiMethods = containingClass.findMethodsByName(methodName, true);
|
||||
for (PsiMethod method : psiMethods) {
|
||||
if (AnnotationUtil.isAnnotated(method, TestNGUtil.TEST_ANNOTATION_FQN, false) &&
|
||||
@@ -569,19 +610,19 @@ public class SearchingForTestsTask extends SearchForTestsTask {
|
||||
|
||||
private static boolean appendMember(final PsiMember psiMember,
|
||||
final Set<PsiMember> underConsideration,
|
||||
final Map<PsiClass, Collection<PsiMethod>> results) {
|
||||
final Map<PsiClass, Map<PsiMethod, List<String>>> results) {
|
||||
boolean result = false;
|
||||
final PsiClass psiClass = psiMember instanceof PsiClass ? ((PsiClass)psiMember) : psiMember.getContainingClass();
|
||||
Collection<PsiMethod> psiMethods = results.get(psiClass);
|
||||
Map<PsiMethod, List<String>> psiMethods = results.get(psiClass);
|
||||
if (psiMethods == null) {
|
||||
psiMethods = new LinkedHashSet<PsiMethod>();
|
||||
psiMethods = new LinkedHashMap<PsiMethod, List<String>>();
|
||||
results.put(psiClass, psiMethods);
|
||||
if (psiMember instanceof PsiClass) {
|
||||
result = underConsideration.add(psiMember);
|
||||
}
|
||||
}
|
||||
if (psiMember instanceof PsiMethod) {
|
||||
final boolean add = psiMethods.add((PsiMethod)psiMember);
|
||||
final boolean add = psiMethods.put((PsiMethod)psiMember, Collections.<String>emptyList()) != null;
|
||||
if (add) {
|
||||
return underConsideration.add(psiMember);
|
||||
}
|
||||
|
||||
+1
-1
@@ -69,7 +69,7 @@ public abstract class TestNGConfigurationProducer extends JavaRunConfigurationPr
|
||||
return false;
|
||||
}
|
||||
|
||||
protected static String getInvocationNumber(String str) {
|
||||
public static String getInvocationNumber(String str) {
|
||||
final int indexOf = str.indexOf(IDEATestNGRemoteListener.INVOCATION_NUMBER);
|
||||
if (indexOf > 0) {
|
||||
final int lastIdx = str.indexOf(")", indexOf);
|
||||
|
||||
@@ -94,7 +94,7 @@ public class TestClassFilter implements ClassFilter.ClassFilterWithScope
|
||||
return true;
|
||||
}
|
||||
|
||||
return includeConfig && TestNGUtil.hasConfig(psiClass);
|
||||
return includeConfig && TestNGUtil.hasConfig(psiClass, TestNGUtil.CONFIG_ANNOTATIONS_FQN_NO_TEST_LEVEL);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@ package com.theoryinpractice.testng.ui;
|
||||
|
||||
import com.intellij.execution.testframework.TestConsoleProperties;
|
||||
import com.intellij.execution.testframework.TestTreeView;
|
||||
import com.theoryinpractice.testng.model.TestNGConsoleProperties;
|
||||
import com.theoryinpractice.testng.model.TestNodeDescriptor;
|
||||
import com.theoryinpractice.testng.model.TestProxy;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -25,7 +24,6 @@ import org.jetbrains.annotations.NotNull;
|
||||
import javax.swing.tree.DefaultMutableTreeNode;
|
||||
import javax.swing.tree.TreeCellRenderer;
|
||||
import javax.swing.tree.TreePath;
|
||||
import javax.swing.tree.TreeSelectionModel;
|
||||
|
||||
/**
|
||||
* @author Hani Suleiman Date: Aug 1, 2005 Time: 11:33:12 AM
|
||||
@@ -54,9 +52,4 @@ public class TestNGTestTreeView extends TestTreeView {
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getSelectionMode() {
|
||||
return TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION;
|
||||
}
|
||||
}
|
||||
+19
-9
@@ -5,9 +5,9 @@ import com.intellij.execution.Executor;
|
||||
import com.intellij.execution.Location;
|
||||
import com.intellij.execution.actions.JavaRerunFailedTestsAction;
|
||||
import com.intellij.execution.configurations.RunProfileState;
|
||||
import com.intellij.execution.junit2.PsiMemberParameterizedLocation;
|
||||
import com.intellij.execution.runners.ExecutionEnvironment;
|
||||
import com.intellij.execution.testframework.AbstractTestProxy;
|
||||
import com.intellij.execution.testframework.SourceScope;
|
||||
import com.intellij.execution.testframework.TestConsoleProperties;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.module.Module;
|
||||
@@ -22,12 +22,11 @@ import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.theoryinpractice.testng.configuration.SearchingForTestsTask;
|
||||
import com.theoryinpractice.testng.configuration.TestNGConfiguration;
|
||||
import com.theoryinpractice.testng.configuration.TestNGConfigurationProducer;
|
||||
import com.theoryinpractice.testng.configuration.TestNGRunnableState;
|
||||
import com.theoryinpractice.testng.util.TestNGUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.ServerSocket;
|
||||
import java.util.*;
|
||||
|
||||
public class RerunFailedTestsAction extends JavaRerunFailedTestsAction {
|
||||
@@ -53,8 +52,8 @@ public class RerunFailedTestsAction extends JavaRerunFailedTestsAction {
|
||||
public SearchingForTestsTask createSearchingForTestsTask() {
|
||||
return new SearchingForTestsTask(myServerSocket, getConfiguration(), myTempFile, client) {
|
||||
@Override
|
||||
protected void fillTestObjects(final Map<PsiClass, Collection<PsiMethod>> classes) throws CantRunException {
|
||||
final HashMap<PsiClass, Collection<PsiMethod>> fullClassList = ContainerUtil.newHashMap();
|
||||
protected void fillTestObjects(final Map<PsiClass, Map<PsiMethod, List<String>>> classes) throws CantRunException {
|
||||
final HashMap<PsiClass, Map<PsiMethod, List<String>>> fullClassList = ContainerUtil.newHashMap();
|
||||
super.fillTestObjects(fullClassList);
|
||||
for (final PsiClass aClass : fullClassList.keySet()) {
|
||||
if (!ApplicationManager.getApplication().runReadAction(new Computable<Boolean>() {
|
||||
@@ -78,7 +77,7 @@ public class RerunFailedTestsAction extends JavaRerunFailedTestsAction {
|
||||
}
|
||||
}
|
||||
|
||||
private void includeFailedTestWithDependencies(Map<PsiClass, Collection<PsiMethod>> classes,
|
||||
private void includeFailedTestWithDependencies(Map<PsiClass, Map<PsiMethod, List<String>>> classes,
|
||||
GlobalSearchScope scope,
|
||||
Project project,
|
||||
AbstractTestProxy proxy) {
|
||||
@@ -95,12 +94,23 @@ public class RerunFailedTestsAction extends JavaRerunFailedTestsAction {
|
||||
psiClass = (PsiClass)elt;
|
||||
}
|
||||
}
|
||||
Collection<PsiMethod> psiMethods = classes.get(psiClass);
|
||||
Map<PsiMethod, List<String>> psiMethods = classes.get(psiClass);
|
||||
if (psiMethods == null) {
|
||||
psiMethods = new ArrayList<PsiMethod>();
|
||||
psiMethods = new LinkedHashMap<PsiMethod, List<String>>();
|
||||
classes.put(psiClass, psiMethods);
|
||||
}
|
||||
psiMethods.add(psiMethod);
|
||||
List<String> strings = psiMethods.get(psiMethod);
|
||||
if (strings == null) {
|
||||
strings = new ArrayList<String>();
|
||||
}
|
||||
if (location instanceof PsiMemberParameterizedLocation) {
|
||||
final String paramSetName = ((PsiMemberParameterizedLocation)location).getParamSetName();
|
||||
final String invocationNumber = TestNGConfigurationProducer.getInvocationNumber(paramSetName);
|
||||
if (invocationNumber != null) {
|
||||
strings.add(invocationNumber);
|
||||
}
|
||||
}
|
||||
psiMethods.put(psiMethod, strings);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,6 @@ import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.ModuleRootModificationUtil;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.io.JarUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.VfsUtil;
|
||||
@@ -91,6 +90,20 @@ public class TestNGUtil {
|
||||
AfterTest.class.getName()
|
||||
};
|
||||
|
||||
@SuppressWarnings("deprecation") public static final String[] CONFIG_ANNOTATIONS_FQN_NO_TEST_LEVEL = {
|
||||
Configuration.class.getName(),
|
||||
Factory.class.getName(),
|
||||
ObjectFactory.class.getName(),
|
||||
BeforeClass.class.getName(),
|
||||
BeforeGroups.class.getName(),
|
||||
BeforeSuite.class.getName(),
|
||||
BeforeTest.class.getName(),
|
||||
AfterClass.class.getName(),
|
||||
AfterGroups.class.getName(),
|
||||
AfterSuite.class.getName(),
|
||||
AfterTest.class.getName()
|
||||
};
|
||||
|
||||
@NonNls
|
||||
private static final String[] CONFIG_JAVADOC_TAGS = {
|
||||
"testng.configuration",
|
||||
@@ -113,19 +126,24 @@ public class TestNGUtil {
|
||||
private static final String SUITE_TAG_NAME = "suite";
|
||||
|
||||
public static boolean hasConfig(PsiModifierListOwner element) {
|
||||
return hasConfig(element, CONFIG_ANNOTATIONS_FQN);
|
||||
}
|
||||
|
||||
public static boolean hasConfig(PsiModifierListOwner element,
|
||||
String[] configAnnotationsFqn) {
|
||||
if (element instanceof PsiClass) {
|
||||
for (PsiMethod method : ((PsiClass)element).getAllMethods()) {
|
||||
if (isConfigMethod(method)) return true;
|
||||
if (isConfigMethod(method, configAnnotationsFqn)) return true;
|
||||
}
|
||||
} else {
|
||||
if (!(element instanceof PsiMethod)) return false;
|
||||
return isConfigMethod((PsiMethod)element);
|
||||
return isConfigMethod((PsiMethod)element, configAnnotationsFqn);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean isConfigMethod(PsiMethod method) {
|
||||
for (String fqn : CONFIG_ANNOTATIONS_FQN) {
|
||||
private static boolean isConfigMethod(PsiMethod method, String[] configAnnotationsFqn) {
|
||||
for (String fqn : configAnnotationsFqn) {
|
||||
if (AnnotationUtil.isAnnotated(method, fqn, false)) return true;
|
||||
}
|
||||
|
||||
@@ -191,21 +209,29 @@ public class TestNGUtil {
|
||||
if (element instanceof PsiClass) {
|
||||
PsiClass psiClass = (PsiClass) element;
|
||||
for (PsiMethod method : psiClass.getAllMethods()) {
|
||||
if (AnnotationUtil.isAnnotated(method, TEST_ANNOTATION_FQN, false, true)) return true;
|
||||
PsiAnnotation annotation = AnnotationUtil.findAnnotation(method, true, TEST_ANNOTATION_FQN);
|
||||
if (annotation != null) {
|
||||
if (checkDisabled) {
|
||||
if (isDisabled(annotation)) continue;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (AnnotationUtil.isAnnotated(method, FACTORY_ANNOTATION_FQN, false, true)) return true;
|
||||
if (hasTestJavaDoc(method, checkJavadoc)) return true;
|
||||
}
|
||||
return AnnotationUtil.isAnnotated(element, TEST_ANNOTATION_FQN, true, true);
|
||||
return false;
|
||||
} else if (element instanceof PsiMethod) {
|
||||
//if it's a method, we check if the class it's in has a global @Test annotation
|
||||
PsiClass psiClass = ((PsiMethod)element).getContainingClass();
|
||||
if (psiClass != null) {
|
||||
if (AnnotationUtil.isAnnotated(psiClass, TEST_ANNOTATION_FQN, true, true)) {
|
||||
final PsiAnnotation annotation = AnnotationUtil.findAnnotation(psiClass, true, TEST_ANNOTATION_FQN);
|
||||
if (annotation != null) {
|
||||
if (checkDisabled && isDisabled(annotation)) return false;
|
||||
//even if it has a global test, we ignore private methods
|
||||
boolean isPrivate = element.hasModifierProperty(PsiModifier.PRIVATE);
|
||||
return !isPrivate && !element.hasModifierProperty(PsiModifier.STATIC) && !hasConfig(element);
|
||||
}
|
||||
if (hasTestJavaDoc(psiClass, checkJavadoc)) return true;
|
||||
else if (hasTestJavaDoc(psiClass, checkJavadoc)) return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -73,8 +73,8 @@ public class IDEARemoteTestNG extends TestNG {
|
||||
final HashMap<String, String> map = new HashMap<String, String>();
|
||||
map.put("count", String.valueOf(testCount));
|
||||
System.out.println(ServiceMessage.asString("testCount", map));
|
||||
addListener((ISuiteListener) new IDEATestNGRemoteListener(myParam));
|
||||
addListener((ITestListener) new IDEATestNGRemoteListener(myParam));
|
||||
addListener((ISuiteListener) new IDEATestNGRemoteListener());
|
||||
addListener((ITestListener) new IDEATestNGRemoteListener());
|
||||
super.run();
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -7,6 +7,7 @@ import org.testng.internal.IResultListener;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@@ -16,25 +17,29 @@ import java.util.Map;
|
||||
public class IDEATestNGRemoteListener implements ISuiteListener, IResultListener{
|
||||
|
||||
public static final String INVOCATION_NUMBER = "invocation number: ";
|
||||
private final String myParam;
|
||||
private String myCurrentClassName;
|
||||
private String myMethodName;
|
||||
private int myInvocationCount = 0;
|
||||
|
||||
public IDEATestNGRemoteListener(String param) {
|
||||
myParam = param;
|
||||
public void onConfigurationSuccess(ITestResult result) {
|
||||
final String className = result.getTestClass().getName();
|
||||
System.out.println("##teamcity[testSuiteStarted name=\'" + className + "\']");
|
||||
final String methodName = result.getMethod().getMethodName();
|
||||
System.out.println("##teamcity[testStarted name=\'" + methodName + "\']");
|
||||
onTestSuccess(result);
|
||||
System.out.println("\n##teamcity[testSuiteFinished name=\'" + className + "\']");
|
||||
}
|
||||
|
||||
public void onConfigurationSuccess(ITestResult itr) {
|
||||
//won't be called
|
||||
}
|
||||
|
||||
public void onConfigurationFailure(ITestResult itr) {
|
||||
//won't be called
|
||||
public void onConfigurationFailure(ITestResult result) {
|
||||
final String className = result.getTestClass().getName();
|
||||
System.out.println("##teamcity[testSuiteStarted name=\'" + className + "\']");
|
||||
final String methodName = result.getMethod().getMethodName();
|
||||
System.out.println("##teamcity[testStarted name=\'" + methodName + "\']");
|
||||
onTestFailure(result);
|
||||
System.out.println("\n##teamcity[testSuiteFinished name=\'" + className + "\']");
|
||||
}
|
||||
|
||||
public void onConfigurationSkip(ITestResult itr) {
|
||||
//won't be called
|
||||
}
|
||||
|
||||
public void onStart(ISuite suite) {
|
||||
@@ -68,14 +73,14 @@ public class IDEATestNGRemoteListener implements ISuiteListener, IResultListener
|
||||
private String getMethodName(ITestResult result, boolean changeCount) {
|
||||
String methodName = result.getMethod().getMethodName();
|
||||
final Object[] parameters = result.getParameters();
|
||||
if (changeCount) {
|
||||
if (!methodName.equals(myMethodName)) {
|
||||
myInvocationCount = 0;
|
||||
myMethodName = methodName;
|
||||
}
|
||||
if (!methodName.equals(myMethodName)) {
|
||||
myInvocationCount = 0;
|
||||
myMethodName = methodName;
|
||||
}
|
||||
if (parameters.length > 0) {
|
||||
methodName += "[" + parameters[0].toString() + (myParam == null ? (" (" + INVOCATION_NUMBER + myInvocationCount + ")") : "") + "]";
|
||||
final List<Integer> invocationNumbers = result.getMethod().getInvocationNumbers();
|
||||
methodName += "[" + parameters[0].toString() + " (" + INVOCATION_NUMBER +
|
||||
(invocationNumbers.isEmpty() ? myInvocationCount : invocationNumbers.get(myInvocationCount)) + ")" + "]";
|
||||
if (changeCount) {
|
||||
myInvocationCount++;
|
||||
}
|
||||
@@ -84,7 +89,7 @@ public class IDEATestNGRemoteListener implements ISuiteListener, IResultListener
|
||||
}
|
||||
|
||||
public void onTestSuccess(ITestResult result) {
|
||||
System.out.println("##teamcity[testFinished name=\'" + getMethodName(result) + "\']");
|
||||
System.out.println("\n##teamcity[testFinished name=\'" + getMethodName(result) + "\']");
|
||||
}
|
||||
|
||||
public String getTrace(Throwable tr) {
|
||||
@@ -106,11 +111,11 @@ public class IDEATestNGRemoteListener implements ISuiteListener, IResultListener
|
||||
attrs.put("details", trace);
|
||||
attrs.put("error", "true");
|
||||
System.out.println(ServiceMessage.asString(ServiceMessageTypes.TEST_FAILED, attrs));
|
||||
System.out.println("##teamcity[testFinished name=\'" + methodName + "\']");
|
||||
System.out.println("\n##teamcity[testFinished name=\'" + methodName + "\']");
|
||||
}
|
||||
|
||||
public void onTestSkipped(ITestResult result) {
|
||||
System.out.println("##teamcity[testFinished name=\'" + getMethodName(result) + "\']");
|
||||
System.out.println("\n##teamcity[testFinished name=\'" + getMethodName(result) + "\']");
|
||||
}
|
||||
|
||||
public void onTestFailedButWithinSuccessPercentage(ITestResult result) {
|
||||
|
||||
Reference in New Issue
Block a user