Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/language-tools/java.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ export class JavaLanguageTools implements LanguageTools {
testCaseName = match.groups.lookupKey
}

// xml files can include trailing parentheses, which aren't part of the original test filter.
testCaseName = testCaseName.replace(/\(\)$/, '')

// Use the class name as the base, and append the test case name if available.
let result = testCaseData.className
if (testCaseName.length > 0) result += `.${testCaseName}`
Expand Down
3 changes: 2 additions & 1 deletion src/test-runner/run-tracker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,9 @@ export class TestRunTracker implements TaskOriginHandlers {
}

if (!hasMatch) {
this.run.appendOutput('\n\r')
this.run.appendOutput(
`Updating ${testFinishData.displayName}: Unable to match this test result to an item in this run.\n`
`Updating ${testFinishData.displayName}: Unable to match this test result to an item in this run.`
)
}
}
Expand Down
41 changes: 40 additions & 1 deletion src/test/suite/language-tools/java.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ suite('Java Language Tools', () => {
className: 'com.example.ClassName',
},
},
expected: 'com.example.ClassName.!@#$%^&*()',
expected: 'com.example.ClassName.!@#$%^&*',
},
{
description: 'empty string as displayName',
Expand All @@ -367,6 +367,45 @@ suite('Java Language Tools', () => {
},
expected: 'com.example.ClassName',
},
{
description: 'test method with parentheses (JUnit 5 format)',
input: {
displayName: 'testMethod()',
status: TestStatus.Passed,
dataKind: TestFinishDataKind.JUnitStyleTestCaseData,
data: {
time: 0.5,
className: 'com.example.ClassName',
},
},
expected: 'com.example.ClassName.testMethod',
},
{
description: 'parameterized test with parentheses',
input: {
displayName: 'testMethod()[example1]',
status: TestStatus.Passed,
dataKind: TestFinishDataKind.JUnitStyleTestCaseData,
data: {
time: 0.5,
className: 'com.example.ClassName',
},
},
expected: 'com.example.ClassName.testMethod',
},
{
description: 'test method with parentheses but not at end',
input: {
displayName: 'testMethod()WithMore',
status: TestStatus.Passed,
dataKind: TestFinishDataKind.JUnitStyleTestCaseData,
data: {
time: 0.5,
className: 'com.example.ClassName',
},
},
expected: 'com.example.ClassName.testMethod()WithMore',
},
]

for (const testCase of testCases) {
Expand Down