-
Notifications
You must be signed in to change notification settings - Fork 137
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Cannot run normal JUnit 5 test methods with multiple parameters (#…
…1535) Signed-off-by: sheche <[email protected]>
- Loading branch information
Showing
4 changed files
with
59 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -427,7 +427,7 @@ org.opentest4j.AssertionFailedError: expected: <1> but was: <2> | |
|
||
const analyzer = new JUnitRunnerResultAnalyzer(runnerContext); | ||
|
||
// We need to stub this method to avoid isssues with the TestController | ||
// We need to stub this method to avoid issues with the TestController | ||
// not being set up in the non-test version of the utils file. | ||
const stub = sinon.stub(analyzer, "enlistDynamicMethodToTestMapping"); | ||
const dummy = generateTestItem(testController, '[__INVOCATION__]-dummy', TestKind.JUnit5, new Range(10, 0, 16, 0)); | ||
|
@@ -438,4 +438,35 @@ org.opentest4j.AssertionFailedError: expected: <1> but was: <2> | |
sinon.assert.calledWith(passedSpy, dummy); | ||
}); | ||
|
||
test("can handle normal test method with multiple arguments", () => { | ||
const testItem = generateTestItem(testController, '[email protected]#test(Vertx,VertxTestContext)', TestKind.JUnit5, new Range(10, 0, 16, 0)); | ||
const testRunRequest = new TestRunRequest([testItem], []); | ||
const testRun = testController.createTestRun(testRunRequest); | ||
const startedSpy = sinon.spy(testRun, 'started'); | ||
const passedSpy = sinon.spy(testRun, 'passed'); | ||
const testRunnerOutput = `%TESTC 1 v2 | ||
%TSTTREE2,junit5.VertxTest,true,1,false,1,VertxTest,,[engine:junit-jupiter]/[class:junit5.VertxTest] | ||
%TSTTREE3,test(junit5.VertxTest),false,1,false,2,test(Vertx\\, VertxTestContext),io.vertx.core.Vertx\\, io.vertx.junit5.VertxTestContext,[engine:junit-jupiter]/[class:junit5.VertxTest]/[method:test(io.vertx.core.Vertx\\, io.vertx.junit5.VertxTestContext)] | ||
%TESTS 3,test(junit5.VertxTest) | ||
%TESTE 3,test(junit5.VertxTest) | ||
%RUNTIME1066`; | ||
const runnerContext: IRunTestContext = { | ||
isDebug: false, | ||
kind: TestKind.JUnit5, | ||
projectName: 'junit', | ||
testItems: [testItem], | ||
testRun: testRun, | ||
workspaceFolder: workspace.workspaceFolders?.[0]!, | ||
}; | ||
|
||
const analyzer = new JUnitRunnerResultAnalyzer(runnerContext); | ||
|
||
analyzer.analyzeData(testRunnerOutput); | ||
|
||
sinon.assert.calledWith(startedSpy, testItem); | ||
sinon.assert.calledWith(passedSpy, testItem); | ||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
test/test-projects/junit/src/test/java/junit5/VertxTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package junit5; | ||
|
||
import io.vertx.core.Vertx; | ||
import io.vertx.junit5.VertxExtension; | ||
import io.vertx.junit5.VertxTestContext; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
|
||
@ExtendWith(VertxExtension.class) | ||
public class VertxTest { | ||
|
||
// test normal methods with multiple parameters | ||
@Test | ||
void test(Vertx vertx, VertxTestContext testContext) throws InterruptedException { | ||
testContext.completeNow(); | ||
} | ||
|
||
} |