Search in sources :

Example 16 with Runner

use of org.junit.runner.Runner in project jena by apache.

the class AbstractRunnerOfTests method prepareTests.

public static void prepareTests(EarlReport report, RunnerOneManifest level, Manifest manifest, Function<ManifestEntry, Runnable> maker, String prefix) {
    manifest.entries().forEach(entry -> {
        String label = prepareTestLabel(entry, prefix);
        Runnable runnable = maker.apply(entry);
        if (runnable != null) {
            Runner r = new RunnerOneTest(label, runnable, entry.getURI(), report);
            level.add(r);
        }
    });
}
Also used : Runner(org.junit.runner.Runner) ParentRunner(org.junit.runners.ParentRunner)

Example 17 with Runner

use of org.junit.runner.Runner in project junit4 by junit-team.

the class TheoryTestUtils method runTheoryClass.

public static Result runTheoryClass(Class<?> testClass) throws InitializationError {
    Runner theoryRunner = new Theories(testClass);
    Request request = Request.runner(theoryRunner);
    return new JUnitCore().run(request);
}
Also used : Runner(org.junit.runner.Runner) JUnitCore(org.junit.runner.JUnitCore) Theories(org.junit.experimental.theories.Theories) Request(org.junit.runner.Request)

Example 18 with Runner

use of org.junit.runner.Runner in project junit4 by junit-team.

the class MaxStarterTest method correctErrorFromHalfMalformedTest.

@Test
public void correctErrorFromHalfMalformedTest() {
    Request request = Request.aClass(HalfMalformedJUnit38TestMethod.class);
    JUnitCore core = new JUnitCore();
    Request sorted = fMax.sortRequest(request);
    Runner runner = sorted.getRunner();
    Result result = core.run(runner);
    Failure failure = result.getFailures().get(0);
    assertThat(failure.toString(), containsString("MalformedJUnit38TestMethod"));
    assertThat(failure.toString(), containsString("testNothing"));
    assertThat(failure.toString(), containsString("isn't public"));
}
Also used : JUnit38ClassRunner(org.junit.internal.runners.JUnit38ClassRunner) Runner(org.junit.runner.Runner) JUnitCore(org.junit.runner.JUnitCore) Request(org.junit.runner.Request) Failure(org.junit.runner.notification.Failure) Result(org.junit.runner.Result) Test(org.junit.Test)

Example 19 with Runner

use of org.junit.runner.Runner in project junit4 by junit-team.

the class MaxStarterTest method correctErrorFromMalformedTest.

@Test
public void correctErrorFromMalformedTest() {
    Request request = Request.aClass(MalformedJUnit38TestMethod.class);
    JUnitCore core = new JUnitCore();
    Request sorted = fMax.sortRequest(request);
    Runner runner = sorted.getRunner();
    Result result = core.run(runner);
    Failure failure = result.getFailures().get(0);
    assertThat(failure.toString(), containsString("MalformedJUnit38TestMethod"));
    assertThat(failure.toString(), containsString("testNothing"));
    assertThat(failure.toString(), containsString("isn't public"));
}
Also used : JUnit38ClassRunner(org.junit.internal.runners.JUnit38ClassRunner) Runner(org.junit.runner.Runner) JUnitCore(org.junit.runner.JUnitCore) Request(org.junit.runner.Request) Failure(org.junit.runner.notification.Failure) Result(org.junit.runner.Result) Test(org.junit.Test)

Example 20 with Runner

use of org.junit.runner.Runner in project ceylon-compiler by ceylon.

the class CeylonModuleRunner method compileAndRun.

private void compileAndRun(File srcDir, File resDir, File outRepo, String[] modules, String[] dependencies, String[] options, Set<String> removeAtRuntime, String[] modulesUsingCheckFunction, String[] modulesUsingCheckModule) throws Exception {
    // Compile all the .ceylon files into a .car
    Context context = new Context();
    final ErrorCollector listener = new ErrorCollector();
    // can't create it until Log
    CeyloncFileManager.preRegister(context);
    // has been set up
    CeylonLog.preRegister(context);
    context.put(DiagnosticListener.class, listener);
    com.redhat.ceylon.compiler.java.launcher.Main compiler = new com.redhat.ceylon.compiler.java.launcher.Main("ceylonc");
    List<String> args = new ArrayList<>();
    // args.add("-verbose:code");
    args.add("-g");
    args.add("-src");
    args.add(srcDir.getCanonicalPath());
    args.add("-res");
    args.add(resDir.getCanonicalPath());
    args.add("-out");
    args.add(outRepo.getAbsolutePath());
    for (String option : options) {
        args.add(option);
    }
    for (String module : modules) args.add(module);
    for (String module : dependencies) args.add(module);
    compiler.compile(args.toArray(new String[args.size()]), context);
    TreeSet<CompilerError> errors = listener.get(Kind.ERROR);
    if (!errors.isEmpty()) {
        List<Runner> errorRunners = new LinkedList<Runner>();
        for (final CompilerError compileError : errors) {
            createFailingTest(errorRunners, compileError.filename, new CompilationException(compileError.toString()));
        }
        for (Runner errorRunner : errorRunners) {
            children.put(errorRunner, errorRunner.getDescription());
        }
    }
    // remove what we need for runtime
    for (String module : removeAtRuntime) {
        File moduleFolder = new File(outRepo, module.replace('.', File.separatorChar));
        FileUtil.delete(moduleFolder);
    }
    for (String module : modules) {
        postCompile(context, listener, module, srcDir, dependencies, removeAtRuntime, modulesUsingCheckFunction, modulesUsingCheckModule);
    }
}
Also used : Context(com.sun.tools.javac.util.Context) ArtifactContext(com.redhat.ceylon.cmr.api.ArtifactContext) Runner(org.junit.runner.Runner) ParentRunner(org.junit.runners.ParentRunner) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) Main(com.redhat.ceylon.compiler.java.runtime.Main) File(java.io.File)

Aggregations

Runner (org.junit.runner.Runner)64 Test (org.junit.Test)21 Description (org.junit.runner.Description)14 ParentRunner (org.junit.runners.ParentRunner)13 ArrayList (java.util.ArrayList)12 JUnitCore (org.junit.runner.JUnitCore)11 Request (org.junit.runner.Request)11 RunNotifier (org.junit.runner.notification.RunNotifier)11 Filter (org.junit.runner.manipulation.Filter)10 NoTestsRemainException (org.junit.runner.manipulation.NoTestsRemainException)9 Result (org.junit.runner.Result)8 Method (java.lang.reflect.Method)7 Failure (org.junit.runner.notification.Failure)7 InitializationError (org.junit.runners.model.InitializationError)7 JUnit38ClassRunner (org.junit.internal.runners.JUnit38ClassRunner)5 RunnerSpy (org.junit.runner.RunnerSpy)5 LinkedList (java.util.LinkedList)4 BlockJUnit4ClassRunner (org.junit.runners.BlockJUnit4ClassRunner)4 File (java.io.File)3 ImmutableMap (com.google.common.collect.ImmutableMap)2