-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure ITestContext available for JUnit4 tests
Closes #2792
- Loading branch information
1 parent
7070b02
commit 8630a7e
Showing
6 changed files
with
71 additions
and
4 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
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
9 changes: 9 additions & 0 deletions
9
testng-core/src/test/java/test/junit4/issue2792/TestClassSample.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,9 @@ | ||
package test.junit4.issue2792; | ||
|
||
import org.junit.Test; | ||
|
||
public class TestClassSample { | ||
|
||
@Test | ||
public void testMethod() {} | ||
} |
31 changes: 31 additions & 0 deletions
31
testng-core/src/test/java/test/junit4/issue2792/TestContextGatheringListener.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,31 @@ | ||
package test.junit4.issue2792; | ||
|
||
import java.util.Objects; | ||
import org.testng.IInvokedMethod; | ||
import org.testng.IInvokedMethodListener; | ||
import org.testng.ITestListener; | ||
import org.testng.ITestResult; | ||
|
||
public class TestContextGatheringListener implements IInvokedMethodListener, ITestListener { | ||
|
||
private boolean testContextFoundOnTestStart = false; | ||
private boolean testContextFoundOnAfterInvocation = false; | ||
|
||
public boolean isTestContextFoundOnAfterInvocation() { | ||
return testContextFoundOnAfterInvocation; | ||
} | ||
|
||
public boolean isTestContextFoundOnTestStart() { | ||
return testContextFoundOnTestStart; | ||
} | ||
|
||
@Override | ||
public void afterInvocation(IInvokedMethod method, ITestResult testResult) { | ||
testContextFoundOnAfterInvocation = Objects.nonNull(testResult.getTestContext()); | ||
} | ||
|
||
@Override | ||
public void onTestStart(ITestResult result) { | ||
testContextFoundOnTestStart = Objects.nonNull(result.getTestContext()); | ||
} | ||
} |