-
-
Notifications
You must be signed in to change notification settings - Fork 379
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Caffeine junit & testng suites seem to pass
- Loading branch information
Showing
9 changed files
with
92 additions
and
107 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
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,42 +1,74 @@ | ||
package mill.testng; | ||
|
||
|
||
import org.testng.*; | ||
import sbt.testing.EventHandler; | ||
import sbt.testing.Logger; | ||
|
||
import org.testng.CommandLineArgs; | ||
import org.testng.TestNG; | ||
|
||
import com.beust.jcommander.JCommander; | ||
|
||
public class TestNGInstance { | ||
Logger[] loggers; | ||
ConfigurableTestNG configurableTestNG = new ConfigurableTestNG(); | ||
public TestNGInstance(Logger[] loggers){ | ||
this.loggers = loggers; | ||
import java.net.URLClassLoader; | ||
import java.util.Arrays; | ||
|
||
class TestNGListener implements ITestListener{ | ||
EventHandler basket; | ||
String lastName = ""; | ||
public TestNGListener(EventHandler basket){ | ||
this.basket = basket; | ||
} | ||
TestNGInstance loadingClassesFrom(ClassLoader testClassLoader){ | ||
configurableTestNG.addClassLoader(testClassLoader); | ||
return TestNGInstance.this; | ||
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); | ||
} | ||
} | ||
TestNGInstance using(String[] testOptions){ | ||
CommandLineArgs args = new CommandLineArgs(); | ||
new JCommander(args, testOptions); // args is an output parameter of the constructor! | ||
configurableTestNG.configure(args); | ||
return TestNGInstance.this; | ||
|
||
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)); | ||
} | ||
|
||
TestNGInstance storingEventsIn(EventRecorder basket){ | ||
configurableTestNG.addListener(basket); | ||
return TestNGInstance.this; | ||
public void onTestSkipped(ITestResult iTestResult) { | ||
System.out.print('-'); | ||
basket.handle(ResultEvent.skipped(iTestResult)); | ||
} | ||
|
||
static void start(TestNGInstance testNG){ | ||
testNG.configurableTestNG.run(); | ||
public void onTestFailedButWithinSuccessPercentage(ITestResult iTestResult) { | ||
basket.handle(ResultEvent.failure(iTestResult)); | ||
} | ||
static TestNGInstance loggingTo(Logger[] loggers){ return new TestNGInstance(loggers); } | ||
|
||
public void onStart(ITestContext iTestContext) {} | ||
|
||
public void onFinish(ITestContext iTestContext) {} | ||
} | ||
|
||
public class TestNGInstance extends TestNG{ | ||
public TestNGInstance(Logger[] loggers, | ||
ClassLoader testClassLoader, | ||
String[] testOptions, | ||
String suiteName, | ||
EventHandler eventHandler) { | ||
addClassLoader(testClassLoader); | ||
|
||
class ConfigurableTestNG extends TestNG{ // the TestNG method we need is protected | ||
public void configure(CommandLineArgs args) { super.configure(args); } | ||
try{ | ||
this.setTestClasses(new Class[]{Class.forName(suiteName)}); | ||
}catch(ClassNotFoundException e){ | ||
throw new RuntimeException(e); | ||
} | ||
this.addListener(new TestNGListener(eventHandler)); | ||
CommandLineArgs args = new CommandLineArgs(); | ||
new JCommander(args, testOptions); // args is an output parameter of the constructor! | ||
configure(args); | ||
} | ||
} | ||
|
||
|
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 was deleted.
Oops, something went wrong.