Skip to content

Commit f343d89

Browse files
authored
refactor - Remove the logic of eliminating spaces in param list (#1700)
1 parent 37cce5c commit f343d89

File tree

5 files changed

+10
-14
lines changed

5 files changed

+10
-14
lines changed

extension.bundle.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,3 @@
22
// Licensed under the MIT license.
33

44
export { activate, deactivate } from './src/extension';
5-
export * from './src/utils/commandUtils';

java-extension/com.microsoft.java.test.plugin/src/main/java/com/microsoft/java/test/plugin/util/TestItemUtils.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,7 @@ public static String parseFullName(IJavaElement element, TestLevel level, TestKi
5353
// them out now.
5454
final String methodName = JavaElementLabelsCore.getElementLabel(element,
5555
JavaElementLabelsCore.ALL_DEFAULT)
56-
.replaceAll("<.*?>", "")
57-
.replaceAll(" ", "");
56+
.replaceAll("<.*?>", "");
5857
return className + "#" + methodName;
5958
} else {
6059
return method.getDeclaringType().getFullyQualifiedName() + "#" + method.getElementName();

java-extension/com.microsoft.java.test.runner/src/main/java/com/microsoft/java/test/runner/testng/TestNGListener.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,12 @@ private String createTestName(ITestResult result) {
7272

7373
for (final Class<?> paramClazz : result.getMethod().getConstructorOrMethod().getMethod().getParameterTypes()) {
7474
params.append(paramClazz.getSimpleName().replaceAll("<.*?>", ""));
75-
params.append(",");
75+
params.append(", ");
7676
}
7777

7878
// Remove the last ", "
7979
if (params.length() > 0) {
80-
params.delete(params.length() - 1, params.length());
80+
params.delete(params.length() - 2, params.length());
8181
}
8282

8383
return className + "#" + methodName + "(" + params.toString() + ")";

src/runners/junitRunner/JUnitRunnerResultAnalyzer.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -224,14 +224,12 @@ export class JUnitRunnerResultAnalyzer extends RunnerResultAnalyzer {
224224
className = `${className}$${nestedClassName}`;
225225
} else if (part.startsWith(JUnitTestPart.TEST_TEMPLATE)) {
226226
const rawMethodName: string = part.substring(JUnitTestPart.TEST_TEMPLATE.length)
227-
.replace(/\\,/g, ',')
228-
.replace(/ /g, '');
227+
.replace(/\\,/g, ',');
229228
// If the method name exists then we want to include the '#' qualifier.
230229
methodName = `#${this.getJUnit5MethodName(rawMethodName)}`;
231230
} else if (part.startsWith(JUnitTestPart.PROPERTY)) {
232231
const rawMethodName: string = part.substring(JUnitTestPart.PROPERTY.length)
233-
.replace(/\\,/g, ',')
234-
.replace(/ /g, '');
232+
.replace(/\\,/g, ',');
235233
// If the method name exists then we want to include the '#' qualifier.
236234
methodName = `#${this.getJUnit5MethodName(rawMethodName)}`;
237235
} else if (part.startsWith(JUnitTestPart.TEST_TEMPLATE_INVOCATION)) {
@@ -285,11 +283,11 @@ export class JUnitRunnerResultAnalyzer extends RunnerResultAnalyzer {
285283
const params: string[] = rawParamsString.split(',');
286284
let paramString: string = '';
287285
params.forEach((param: string) => {
288-
paramString += `${param.substring(param.lastIndexOf('.') + 1)},`;
286+
paramString += `${param.substring(param.lastIndexOf('.') + 1)}, `;
289287
});
290-
// We want to remove the final comma.
288+
// We want to remove the final comma and space.
291289
if (paramString.length > 0) {
292-
paramString = paramString.substring(0, paramString.length - 1);
290+
paramString = paramString.substring(0, paramString.length - 2);
293291
}
294292

295293
const methodName: string = rawName.substring(0, rawName.indexOf('('));

test/suite/JUnitAnalyzer.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ org.opentest4j.AssertionFailedError: expected: <1> but was: <2>
404404
});
405405

406406
test("can handle test cases with more than 3 arguments", () => {
407-
const testItem = generateTestItem(testController, '[email protected]#testMultiArguments(String,String,String)', TestKind.JUnit5, new Range(10, 0, 16, 0));
407+
const testItem = generateTestItem(testController, '[email protected]#testMultiArguments(String, String, String)', TestKind.JUnit5, new Range(10, 0, 16, 0));
408408
const testRunRequest = new TestRunRequest([testItem], []);
409409
const testRun = testController.createTestRun(testRunRequest);
410410
const startedSpy = sinon.spy(testRun, 'started');
@@ -439,7 +439,7 @@ org.opentest4j.AssertionFailedError: expected: <1> but was: <2>
439439
});
440440

441441
test("can handle normal test method with multiple arguments", () => {
442-
const testItem = generateTestItem(testController, '[email protected]#test(Vertx,VertxTestContext)', TestKind.JUnit5, new Range(10, 0, 16, 0));
442+
const testItem = generateTestItem(testController, '[email protected]#test(Vertx, VertxTestContext)', TestKind.JUnit5, new Range(10, 0, 16, 0));
443443
const testRunRequest = new TestRunRequest([testItem], []);
444444
const testRun = testController.createTestRun(testRunRequest);
445445
const startedSpy = sinon.spy(testRun, 'started');

0 commit comments

Comments
 (0)