use of com.intellij.execution.testframework.sm.runner.SMTestProxy in project intellij-community by JetBrains.
the class TestTreeRenderer method customizeCellRenderer.
public void customizeCellRenderer(final JTree tree, final Object value, final boolean selected, final boolean expanded, final boolean leaf, final int row, final boolean hasFocus) {
myRow = row;
myDurationWidth = -1;
final DefaultMutableTreeNode node = (DefaultMutableTreeNode) value;
final Object userObj = node.getUserObject();
if (userObj instanceof SMTRunnerNodeDescriptor) {
final SMTRunnerNodeDescriptor desc = (SMTRunnerNodeDescriptor) userObj;
final SMTestProxy testProxy = desc.getElement();
if (testProxy instanceof SMTestProxy.SMRootTestProxy) {
SMTestProxy.SMRootTestProxy rootTestProxy = (SMTestProxy.SMRootTestProxy) testProxy;
if (node.isLeaf()) {
TestsPresentationUtil.formatRootNodeWithoutChildren(rootTestProxy, this);
} else {
TestsPresentationUtil.formatRootNodeWithChildren(rootTestProxy, this);
}
if (myAdditionalRootFormatter != null) {
myAdditionalRootFormatter.format(rootTestProxy, this);
}
} else {
TestsPresentationUtil.formatTestProxy(testProxy, this);
}
if (TestConsoleProperties.SHOW_INLINE_STATISTICS.value(myConsoleProperties)) {
String durationString = testProxy.getDurationString(myConsoleProperties);
if (durationString != null) {
durationString = " " + durationString;
myDurationWidth = getFontMetrics(getFont()).stringWidth(durationString);
if (((TestTreeView) myTree).isExpandableHandlerVisibleForCurrentRow(myRow)) {
append(durationString);
}
}
}
//Done
return;
}
//strange node
final String text = node.toString();
//no icon
append(text != null ? text : SPACE_STRING, SimpleTextAttributes.GRAYED_ATTRIBUTES);
}
use of com.intellij.execution.testframework.sm.runner.SMTestProxy in project intellij-community by JetBrains.
the class SMTRunnerFiltersTest method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
myProperties = createConsoleProperties();
myResultsViewer = new MockTestResultsViewer(myProperties, mySuite);
TestConsoleProperties.HIDE_PASSED_TESTS.set(myProperties, false);
TestConsoleProperties.HIDE_IGNORED_TEST.set(myProperties, false);
TestConsoleProperties.HIDE_SUCCESSFUL_CONFIG.set(myProperties, true);
myResultsForm = new SMTestRunnerResultsForm(new JLabel(), myProperties);
Disposer.register(myResultsForm, myProperties);
myResultsForm.initUI();
//setup suites tree
mySuite.setStarted();
final SMTestProxy testsSuite = createSuiteProxy("my suite", mySuite);
testsSuite.setStarted();
// passed test
final SMTestProxy testPassed1 = createTestProxy("testPassed1", testsSuite);
testPassed1.setStarted();
testPassed1.setFinished();
// passed config
final SMTestProxy testConfig1 = createTestProxy("testConfig1", testsSuite);
testConfig1.setConfig(true);
testConfig1.setStarted();
testConfig1.setFinished();
//ignored test
final SMTestProxy testIgnored1 = createTestProxy("testIgnored1", testsSuite);
testIgnored1.setStarted();
testIgnored1.setTestIgnored("", "");
testsSuite.setFinished();
mySuite.setFinished();
}
use of com.intellij.execution.testframework.sm.runner.SMTestProxy in project intellij-community by JetBrains.
the class AfterTestEvent method process.
@Override
public void process(@NotNull final TestEventXmlView eventXml) throws TestEventXmlView.XmlParserException {
final String testId = eventXml.getTestId();
final String startTime = eventXml.getEventTestResultStartTime();
final String endTime = eventXml.getEventTestResultEndTime();
final String exceptionMsg = decode(eventXml.getEventTestResultErrorMsg());
final String stackTrace = decode(eventXml.getEventTestResultStackTrace());
final SMTestProxy testProxy = findTestProxy(testId);
if (testProxy == null)
return;
try {
testProxy.setDuration(Long.valueOf(endTime) - Long.valueOf(startTime));
} catch (NumberFormatException ignored) {
}
final CompositeRunnable runInEdt = new CompositeRunnable();
final TestEventResult result = TestEventResult.fromValue(eventXml.getTestEventResultType());
switch(result) {
case SUCCESS:
runInEdt.add(testProxy::setFinished);
break;
case FAILURE:
final String failureType = eventXml.getEventTestResultFailureType();
if ("comparison".equals(failureType)) {
String actualText = decode(eventXml.getEventTestResultActual());
String expectedText = decode(eventXml.getEventTestResultExpected());
final Condition<String> emptyString = StringUtil::isEmpty;
String filePath = ObjectUtils.nullizeByCondition(decode(eventXml.getEventTestResultFilePath()), emptyString);
String actualFilePath = ObjectUtils.nullizeByCondition(decode(eventXml.getEventTestResultActualFilePath()), emptyString);
testProxy.setTestComparisonFailed(exceptionMsg, stackTrace, actualText, expectedText, filePath, actualFilePath);
} else {
Couple<String> comparisonPair = parseComparisonMessage(exceptionMsg, "\nExpected: is \"(.*)\"\n\\s*got: \"(.*)\"\n");
if (comparisonPair == null) {
comparisonPair = parseComparisonMessage(exceptionMsg, "\nExpected: is \"(.*)\"\n\\s*but: was \"(.*)\"");
}
if (comparisonPair == null) {
comparisonPair = parseComparisonMessage(exceptionMsg, "\nExpected: (.*)\n\\s*got: (.*)");
}
if (comparisonPair == null) {
comparisonPair = parseComparisonMessage(exceptionMsg, "\\s*expected same:<(.*)> was not:<(.*)>");
}
if (comparisonPair == null) {
comparisonPair = parseComparisonMessage(exceptionMsg, ".*\\s*expected:<(.*)> but was:<(.*)>");
}
if (comparisonPair == null) {
comparisonPair = parseComparisonMessage(exceptionMsg, "\nExpected: \"(.*)\"\n\\s*but: was \"(.*)\"");
}
final Couple<String> finalComparisonPair = comparisonPair;
runInEdt.add(() -> {
if (finalComparisonPair != null) {
testProxy.setTestComparisonFailed(exceptionMsg, stackTrace, finalComparisonPair.second, finalComparisonPair.first);
} else {
testProxy.setTestFailed(exceptionMsg, stackTrace, "error".equals(failureType));
}
});
}
runInEdt.add(() -> getResultsViewer().onTestFailed(testProxy));
break;
case SKIPPED:
runInEdt.add(() -> {
testProxy.setTestIgnored(null, null);
getResultsViewer().onTestIgnored(testProxy);
});
break;
case UNKNOWN_RESULT:
break;
}
runInEdt.add(() -> getResultsViewer().onTestFinished(testProxy));
addToInvokeLater(runInEdt);
}
use of com.intellij.execution.testframework.sm.runner.SMTestProxy in project intellij-community by JetBrains.
the class DetectClassesToRunTest method testRerunFailedParameterized.
public void testRerunFailedParameterized() throws Exception {
@SuppressWarnings("TestNGDataProvider") final PsiClass aClass = myFixture.addClass("package a; " + "import org.testng.annotations.DataProvider;\n" + "import org.testng.annotations.Test;\n" + "\n" + "import static org.testng.Assert.assertEquals;\n" + "\n" + "public class ATest {\n" + "\n" + " @DataProvider\n" + " public Object[][] testData() {\n" + " return new Object[][]{\n" + " {1},\n" + " {2},\n" + " };\n" + " }\n" + "\n" + " @Test(dataProvider = \"testData\")\n" + " public void test(int in) {\n" + " assertEquals(in, 0);\n" + " }\n" + "}\n");
final LinkedHashMap<PsiClass, Map<PsiMethod, List<String>>> classes = new LinkedHashMap<>();
classes.put(aClass, new HashMap<>());
final GlobalSearchScope projectScope = GlobalSearchScope.projectScope(getProject());
final SMTestProxy testProxy = new SMTestProxy("test", false, "java:test://a.ATest.test[0]");
testProxy.setLocator(new JavaTestLocator());
RerunFailedTestsAction.includeFailedTestWithDependencies(classes, projectScope, getProject(), testProxy);
final SMTestProxy testProxy2 = new SMTestProxy("test", false, "java:test://a.ATest.test[1]");
testProxy2.setLocator(new JavaTestLocator());
RerunFailedTestsAction.includeFailedTestWithDependencies(classes, projectScope, getProject(), testProxy2);
assertEquals(1, classes.size());
final Map<PsiMethod, List<String>> params = classes.get(aClass);
final PsiMethod[] tests = aClass.findMethodsByName("test", false);
assertContainsElements(params.keySet(), tests);
final List<String> paramsToRerun = params.get(tests[0]);
assertEquals(2, paramsToRerun.size());
assertContainsElements(paramsToRerun, "0", "1");
}
use of com.intellij.execution.testframework.sm.runner.SMTestProxy in project intellij-community by JetBrains.
the class TestsPresentationUtilTest method createChildSuiteOfParentSuite.
protected SMTestProxy createChildSuiteOfParentSuite(final String parentName, final String childName) {
final SMTestProxy parentSuite = createSuiteProxy(parentName);
final SMTestProxy childSuite = createTestProxy(childName);
parentSuite.addChild(childSuite);
return childSuite;
}
Aggregations