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
6 changes: 1 addition & 5 deletions src/runners/junitRunner/JUnitRunnerResultAnalyzer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,8 @@ export class JUnitRunnerResultAnalyzer extends BaseRunnerResultAnalyzer {
this.currentTestItem = testId;
const failedResult: ITestResult = Object.assign({}, testResultManager.getResultById(testId), {
id: testId,
status: TestStatus.Fail,
status: data.indexOf(MessageId.ASSUMPTION_FAILED_TEST_PREFIX) > -1 ? TestStatus.Skip : TestStatus.Fail,
});
if (data.indexOf(MessageId.ASSUMPTION_FAILED_TEST_PREFIX) > -1) {
failedResult.status = TestStatus.Skip;
return;
}
updateElapsedTime(failedResult);
testResultManager.storeResult(failedResult);
this.testIds.add(testId);
Expand Down
16 changes: 16 additions & 0 deletions test/maven-junit4-suite/codelens.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,22 @@ suite('Code Lens Tests', function() {
assert.ok(failedDetail!.duration !== undefined, 'Should have execution time');
});

test("Assume failure should mark as skipped", async function() {
const document: TextDocument = await workspace.openTextDocument(Uris.JUNIT4_ASSUME_TEST);
await window.showTextDocument(document);

const codeLensProvider: TestCodeLensProvider = new TestCodeLensProvider();
const codeLens: CodeLens[] = await codeLensProvider.provideCodeLenses(document, Token.cancellationToken);
const command: Command | undefined = codeLens[0].command;
const testItem: ITestItem[] = command!.arguments as ITestItem[];
await commands.executeCommand(command!.command, testItem[0]);

const projectName: string = testItem[0].project;
const skippedDetail: ITestResult| undefined = testResultManager.getResultById(`${projectName}@junit4.AssumeTest#shouldSkip`);
assert.equal(skippedDetail!.status, TestStatus.Skip, 'Should have skipped case');
assert.ok(skippedDetail!.duration !== undefined, 'Should have execution time');
});

teardown(async function() {
// Clear the result cache
testResultManager.dispose();
Expand Down
1 change: 1 addition & 0 deletions test/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export namespace Uris {
export const JUNIT4_RUNWITH: Uri = Uri.file(path.join(TEST_PROJECT_BASE_PATH, JUNIT4_TEST_PACKAGE, 'RunWithAnnotation.java'));
export const JUNIT4_EXCEPTION_BEFORE: Uri = Uri.file(path.join(TEST_PROJECT_BASE_PATH, JUNIT4_TEST_PACKAGE, 'ExceptionInBefore.java'));
export const JUNIT4_PARAMETERIZED_TEST: Uri = Uri.file(path.join(TEST_PROJECT_BASE_PATH, JUNIT4_TEST_PACKAGE, 'ParameterizedTest.java'));
export const JUNIT4_ASSUME_TEST: Uri = Uri.file(path.join(TEST_PROJECT_BASE_PATH, JUNIT4_TEST_PACKAGE, 'AssumeTest.java'));

const MODULAR_GRADLE: string = path.join('modular-gradle', 'src', 'test', 'java', 'com', 'example', 'project');
export const MODULAR_GRADLE_TEST: Uri = Uri.file(path.join(TEST_PROJECT_BASE_PATH, MODULAR_GRADLE, 'GradleModularTest.java'));
Expand Down
12 changes: 12 additions & 0 deletions test/test-projects/junit4/src/test/java/junit4/AssumeTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package junit4;

import org.junit.Test;

import static org.junit.Assume.assumeTrue;

public class AssumeTest {
@Test
public void shouldSkip() {
assumeTrue(false);
}
}