diff options
author | Xavier Coulon | 2014-04-09 03:32:37 +0000 |
---|---|---|
committer | Manju Mathew | 2014-04-09 03:32:37 +0000 |
commit | 93dbc808a9cef680d165b06045426ebbae285502 (patch) | |
tree | 8cd0419c213dc9984d894ec337ae37baa4280be0 | |
parent | 4121c43c62b42c115a15c273a630eca928023709 (diff) | |
download | eclipse.jdt.ui-93dbc808a9cef680d165b06045426ebbae285502.tar.gz eclipse.jdt.ui-93dbc808a9cef680d165b06045426ebbae285502.tar.xz eclipse.jdt.ui-93dbc808a9cef680d165b06045426ebbae285502.zip |
Fixed Bug 102512: [JUnit] test method name cut off before (
Signed-off-by: Xavier Coulon <xcoulon@redhat.com>
3 files changed, 24 insertions, 10 deletions
diff --git a/org.eclipse.jdt.junit.core/src/org/eclipse/jdt/internal/junit/model/TestCaseElement.java b/org.eclipse.jdt.junit.core/src/org/eclipse/jdt/internal/junit/model/TestCaseElement.java index 54b8a91ef3..c4e1dee95e 100644 --- a/org.eclipse.jdt.junit.core/src/org/eclipse/jdt/internal/junit/model/TestCaseElement.java +++ b/org.eclipse.jdt.junit.core/src/org/eclipse/jdt/internal/junit/model/TestCaseElement.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2010 IBM Corporation and others. + * Copyright (c) 2000, 2014 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -7,6 +7,7 @@ * * Contributors: * IBM Corporation - initial API and implementation + * Xavier Coulon <xcoulon@redhat.com> - https://bugs.eclipse.org/bugs/show_bug.cgi?id=102512 - [JUnit] test method name cut off before ( *******************************************************************************/ package org.eclipse.jdt.internal.junit.model; @@ -33,7 +34,7 @@ public class TestCaseElement extends TestElement implements ITestCaseElement { */ public String getTestMethodName() { String testName= getTestName(); - int index= testName.indexOf('('); + int index= testName.lastIndexOf('('); if (index > 0) return testName.substring(0, index); index= testName.indexOf('@'); diff --git a/org.eclipse.jdt.junit.core/src/org/eclipse/jdt/internal/junit/model/TestElement.java b/org.eclipse.jdt.junit.core/src/org/eclipse/jdt/internal/junit/model/TestElement.java index c38031ae9f..de004ac791 100644 --- a/org.eclipse.jdt.junit.core/src/org/eclipse/jdt/internal/junit/model/TestElement.java +++ b/org.eclipse.jdt.junit.core/src/org/eclipse/jdt/internal/junit/model/TestElement.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2013 IBM Corporation and others. + * Copyright (c) 2000, 2014 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -9,6 +9,7 @@ * IBM Corporation - initial API and implementation * Brock Janiczak (brockj@tpg.com.au) * - https://bugs.eclipse.org/bugs/show_bug.cgi?id=102236: [JUnit] display execution time next to each test + * Xavier Coulon <xcoulon@redhat.com> - https://bugs.eclipse.org/bugs/show_bug.cgi?id=102512 - [JUnit] test method name cut off before ( *******************************************************************************/ package org.eclipse.jdt.internal.junit.model; @@ -330,11 +331,15 @@ public abstract class TestElement implements ITestElement { } public static String extractRawClassName(String testNameString) { - int index= testNameString.indexOf('('); + // when testNameString begins and ends with square brackets then it means the + // test is a parameterized test (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=102512) + if (testNameString.indexOf('[') == 0 && testNameString.lastIndexOf(']') == testNameString.length() - 1) { + return testNameString; + } + int index= testNameString.lastIndexOf('('); if (index < 0) return testNameString; - testNameString= testNameString.substring(index + 1); - testNameString= testNameString.substring(0, testNameString.indexOf(')')); + testNameString= testNameString.substring(index + 1, testNameString.lastIndexOf(')')); return testNameString; } diff --git a/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/ui/TestViewer.java b/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/ui/TestViewer.java index e050d66c7b..a496e694a3 100644 --- a/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/ui/TestViewer.java +++ b/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/ui/TestViewer.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2010 IBM Corporation and others. + * Copyright (c) 2000, 2014 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -9,6 +9,8 @@ * IBM Corporation - initial API and implementation * Brock Janiczak (brockj@tpg.com.au) * - https://bugs.eclipse.org/bugs/show_bug.cgi?id=102236: [JUnit] display execution time next to each test + * Xavier Coulon <xcoulon@redhat.com> - https://bugs.eclipse.org/bugs/show_bug.cgi?id=102512 - [JUnit] test method name cut off before ( + *******************************************************************************/ package org.eclipse.jdt.internal.junit.ui; @@ -282,10 +284,16 @@ public class TestViewer { TestElement testElement= (TestElement) selection.getFirstElement(); OpenTestAction action; + String testName= testElement.getTestName(); if (testElement instanceof TestSuiteElement) { - action= new OpenTestAction(fTestRunnerPart, testElement.getTestName()); - } else if (testElement instanceof TestCaseElement){ - TestCaseElement testCase= (TestCaseElement) testElement; + ITestElement[] children= ((TestSuiteElement)testElement).getChildren(); + // if the TestSuiteElement is a parameterized tests i.e. name begins with '[' and ends with ']' + if (testName.indexOf('[') == 0 && testName.lastIndexOf(']') == testName.length() - 1 && children.length > 0 && children[0] instanceof TestCaseElement) + action= new OpenTestAction(fTestRunnerPart, (TestCaseElement)children[0]); + else + action= new OpenTestAction(fTestRunnerPart, testName); + } else if (testElement instanceof TestCaseElement) { + TestCaseElement testCase= (TestCaseElement)testElement; action= new OpenTestAction(fTestRunnerPart, testCase); } else { throw new IllegalStateException(String.valueOf(testElement)); |