diff options
author | Li Haoyi <haoyi.sg@gmail.com> | 2018-12-12 16:56:02 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-12-12 16:56:02 -0800 |
commit | 9ba4cb69331386dfde9bac69dc2d5b22401face3 (patch) | |
tree | 120349e8015ae5717d36bd44209cde6ff9543518 /contrib/testng/src/TestNGInstance.java | |
parent | ea7fceb6e56f53bde3517586dfc57e10a605a524 (diff) | |
download | mill-9ba4cb69331386dfde9bac69dc2d5b22401face3.tar.gz mill-9ba4cb69331386dfde9bac69dc2d5b22401face3.tar.bz2 mill-9ba4cb69331386dfde9bac69dc2d5b22401face3.zip |
collapse boilerplate folder structure within src/ folders (#505)
* collapse boilerplate folder structure within src/ folders
* .
Diffstat (limited to 'contrib/testng/src/TestNGInstance.java')
-rw-r--r-- | contrib/testng/src/TestNGInstance.java | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/contrib/testng/src/TestNGInstance.java b/contrib/testng/src/TestNGInstance.java new file mode 100644 index 00000000..4cf274d3 --- /dev/null +++ b/contrib/testng/src/TestNGInstance.java @@ -0,0 +1,67 @@ +package mill.testng; + + +import org.testng.*; +import sbt.testing.EventHandler; +import sbt.testing.Logger; + +import com.beust.jcommander.JCommander; + +import java.net.URLClassLoader; +import java.util.Arrays; + +class TestNGListener implements ITestListener{ + EventHandler basket; + String lastName = ""; + public TestNGListener(EventHandler basket){ + this.basket = basket; + } + public void onTestStart(ITestResult iTestResult) { + String newName = iTestResult.getTestClass().getName() + " " + iTestResult.getName() + " "; + if(!newName.equals(lastName)){ + if (!lastName.equals("")){ + System.out.println(); + } + lastName = newName; + System.out.print(lastName); + } + } + + public void onTestSuccess(ITestResult iTestResult) { + System.out.print('+'); + basket.handle(ResultEvent.success(iTestResult)); + } + + public void onTestFailure(ITestResult iTestResult) { + System.out.print('X'); + basket.handle(ResultEvent.failure(iTestResult)); + } + + public void onTestSkipped(ITestResult iTestResult) { + System.out.print('-'); + basket.handle(ResultEvent.skipped(iTestResult)); + } + + public void onTestFailedButWithinSuccessPercentage(ITestResult iTestResult) { + basket.handle(ResultEvent.failure(iTestResult)); + } + + public void onStart(ITestContext iTestContext) {} + + public void onFinish(ITestContext iTestContext) {} +} + +public class TestNGInstance extends TestNG{ + public TestNGInstance(Logger[] loggers, + ClassLoader testClassLoader, + CommandLineArgs args, + EventHandler eventHandler) { + addClassLoader(testClassLoader); + + this.addListener(new TestNGListener(eventHandler)); + + configure(args); + } +} + + |