-
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.
Merge pull request #2815 from krmahadevan/fix_2788
Streamline TestResult due to expectedExceptions
- Loading branch information
Showing
5 changed files
with
63 additions
and
3 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
42 changes: 42 additions & 0 deletions
42
testng-core/src/test/java/test/expectedexceptions/issue2788/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,42 @@ | ||
package test.expectedexceptions.issue2788; | ||
|
||
import org.testng.IInvokedMethod; | ||
import org.testng.IInvokedMethodListener; | ||
import org.testng.ITestResult; | ||
import org.testng.annotations.Listeners; | ||
import org.testng.annotations.Test; | ||
import test.expectedexceptions.issue2788.TestClassSample.Local; | ||
|
||
@Listeners(Local.class) | ||
public class TestClassSample { | ||
|
||
@Test(expectedExceptions = NullPointerException.class) | ||
public void sampleTestMethod() {} | ||
|
||
public static class Local implements IInvokedMethodListener { | ||
|
||
public static Local instance; | ||
private boolean pass; | ||
|
||
private static void setInstance(Local localInstance) { | ||
instance = localInstance; | ||
} | ||
|
||
public static Local getInstance() { | ||
return instance; | ||
} | ||
|
||
public Local() { | ||
setInstance(this); | ||
} | ||
|
||
public boolean isPass() { | ||
return pass; | ||
} | ||
|
||
@Override | ||
public void afterInvocation(IInvokedMethod method, ITestResult testResult) { | ||
pass = testResult.isSuccess(); | ||
} | ||
} | ||
} |