use of org.junit.runner.JUnitCore in project ddf by codice.
the class PaxExamRuleTest method validBeforeAndAfter.
@Test
public void validBeforeAndAfter() {
JUnitCore core = new JUnitCore();
Result result = core.run(PassingBeforeExamAndAfterExamTest.class);
assertThat(result.getFailures()).extracting("message").contains(FAILING_TEST_MESSAGE);
assertResultCounts(result, 1);
}
use of org.junit.runner.JUnitCore in project bitsquare by bitsquare.
the class StressTestMailboxMessage method main.
// # MAIN ENTRY POINT
// Inspired by <https://stackoverflow.com/a/9288513> by Marc Peters.
public static void main(String[] args) {
Request request = (args.length == 0) ? Request.aClass(NetworkStressTest.class) : Request.method(NetworkStressTest.class, args[0]);
Result result = new JUnitCore().run(request);
for (Failure f : result.getFailures()) System.err.printf("\n%s\n%s", f, f.getTrace());
System.exit(result.wasSuccessful() ? 0 : 1);
}
use of org.junit.runner.JUnitCore in project sling by apache.
the class TestsManagerImpl method executeTests.
public void executeTests(Collection<String> testNames, Renderer renderer, TestSelector selector) throws Exception {
renderer.title(2, "Running tests");
waitForSystemStartup();
final JUnitCore junit = new JUnitCore();
// Create a test context if we don't have one yet
final boolean createContext = !SlingTestContextProvider.hasContext();
if (createContext) {
SlingTestContextProvider.createContext();
}
try {
junit.addListener(new TestContextRunListenerWrapper(renderer.getRunListener()));
for (String className : testNames) {
renderer.title(3, className);
// If we have a test context, clear its output metadata
if (SlingTestContextProvider.hasContext()) {
SlingTestContextProvider.getContext().output().clear();
}
final String testMethodName = selector == null ? null : selector.getSelectedTestMethodName();
if (testMethodName != null && testMethodName.length() > 0) {
log.debug("Running test method {} from test class {}", testMethodName, className);
junit.run(Request.method(getTestClass(className), testMethodName));
} else {
log.debug("Running test class {}", className);
junit.run(getTestClass(className));
}
}
} finally {
if (createContext) {
SlingTestContextProvider.deleteContext();
}
}
}
use of org.junit.runner.JUnitCore in project bayou by capergroup.
the class FloodGage method run.
/**
* Parses "trials.xml" as found as a resource on the current class path and executes the trials against
* the given Synthesizer reporting progress to the given View.
*
* Expects a trialpack to be on the current classpath.
*
* @param synthesizer the Synthesizer to use for creating programs from draft programs identified in trials.
* @param view the UI component for reporting execution progress.
* @throws IOException if there is a program reading resources (like "trails.xml") on the classpath.
* @throws ParseException if "trials.xml" is not of the expected format
* @throws ClassCastException if "PassProgram" or "PassProgramTest" cannot be loaded from teh current classpath.
*/
void run(Synthesizer synthesizer, View view) throws IOException, ParseException, ClassNotFoundException {
if (synthesizer == null)
throw new NullPointerException("synthesizer");
if (view == null)
throw new NullPointerException("view");
/*
* Parse trials.xml from inside the trialpack (assumed to be on classpath) into a Directive structure.
*/
Directive directive;
{
// We expect the trialpack jar file to be on the classpath. That jar file should have a
// trails.xml file its root directory. So look for it at just "trails.xml" path.
String trailsXml = new String(getResource("trials.xml"), StandardCharsets.UTF_8);
directive = DirectiveXmlV1Parser.makeDefault().parse(trailsXml);
}
/*
* Test the test suite by asserting that all test cases pass when given the pass program.
*
* Stop the program if this is not the case.
*/
// expect PassProgram class inside the trailpack which is assumed to be on the class path
Class passProgram = getClass().getClassLoader().loadClass("PassProgram");
// expect PassProgramTest class inside the trailpack which is assumed to be on the class path
Class passProgramTestSuite = getClass().getClassLoader().loadClass("PassProgramTest");
view.declareTestingTestSuite(passProgramTestSuite, passProgram);
// run the test cases against PassProgram
Result result = new JUnitCore().run(passProgramTestSuite);
view.declareNumberOfTestCasesInSuite(result.getRunCount());
if (// if the pass program did not pass the test suite
result.getFailureCount() > 0) {
for (Failure f : result.getFailures()) view.declarePassProgramTestFailure(f.getTrace());
} else // pass program did pass the test suite, proceed to running the user specified trials
{
List<Trial> trials = makeTrials(directive, DraftBuilderBayou1_1_0::new);
TrialsRunner.runTrails(trials, synthesizer, view);
}
}
use of org.junit.runner.JUnitCore in project vcell by virtualcell.
the class MathVisitor method main.
public static void main(String[] args) {
Request req = Request.method(MathVisitor.class, "batchScan");
JUnitCore core = new JUnitCore();
Result res = core.run(req);
for (Failure f : res.getFailures()) {
System.err.println("Failure: " + f.toString());
}
System.exit(0);
}
Aggregations