Package org.junit.runner.notification

Examples of org.junit.runner.notification.RunNotifier


        response.getWriter().println("Could not find class with name or reference to " + target.substring(1));
        return;
      }

      HegemonRunner runner = new HegemonRunner(c, baseRequest.getQueryString(), this.loadPath);
      RunNotifier notifier = new RunNotifier();
      notifier.addListener(new ResponseListener(response, createCustomTestOutputHandler()));

      startTestClass();
      long start = System.currentTimeMillis();

      response.setContentType("text/html;charset=utf-8");
View Full Code Here


  @Test
  public void timedTests() throws Exception {
    Assume.group(TestGroup.PERFORMANCE);
    Class<TimedSpringRunnerTestCase> testClass = TimedSpringRunnerTestCase.class;
    TrackingRunListener listener = new TrackingRunListener();
    RunNotifier notifier = new RunNotifier();
    notifier.addListener(listener);

    new SpringJUnit4ClassRunner(testClass).run(notifier);
    assertEquals("Verifying number of tests started for test class [" + testClass + "].", 7,
      listener.getTestStartedCount());
    assertEquals("Verifying number of failures for test class [" + testClass + "].", 5,
View Full Code Here

  @Test
  public void expectedExceptions() throws Exception {
    Class<ExpectedExceptionSpringRunnerTestCase> testClass = ExpectedExceptionSpringRunnerTestCase.class;
    TrackingRunListener listener = new TrackingRunListener();
    RunNotifier notifier = new RunNotifier();
    notifier.addListener(listener);

    new SpringJUnit4ClassRunner(testClass).run(notifier);
    assertEquals("Verifying number of failures for test class [" + testClass + "].", 0,
      listener.getTestFailureCount());
    assertEquals("Verifying number of tests started for test class [" + testClass + "].", 1,
View Full Code Here

  }

  @Test
  public void assertRepetitions() throws Exception {
    TrackingRunListener listener = new TrackingRunListener();
    RunNotifier notifier = new RunNotifier();
    notifier.addListener(listener);
    invocationCount.set(0);

    new SpringJUnit4ClassRunner(this.testClass).run(notifier);
    assertEquals("Verifying number of failures for test class [" + this.testClass + "].",
      this.expectedFailureCount, listener.getTestFailureCount());
View Full Code Here

  }

  @Test
  public void runTestAndAssertCounters() throws Exception {
    final TrackingRunListener listener = new TrackingRunListener();
    final RunNotifier notifier = new RunNotifier();
    notifier.addListener(listener);

    new SpringJUnit4ClassRunner(this.clazz).run(notifier);
    assertEquals("Verifying number of failures for test class [" + this.clazz + "].", 1,
      listener.getTestFailureCount());
  }
View Full Code Here

    {
        if (classSingleScriptAnnotation == null) {
            return statement;
        } else {
            final String name = BMRunnerUtil.computeBMScriptName(classSingleScriptAnnotation.value());
            final RunNotifier fnotifier = notifier;
            final Description description = Description.createTestDescription(testKlazz, getName(), classSingleScriptAnnotation);
            final String loadDirectory = BMRunnerUtil.normaliseLoadDirectory(classSingleScriptAnnotation);
            return new Statement() {
                public void evaluate() throws Throwable {
                    try {
                        BMUnit.loadScriptFile(testKlazz, name, loadDirectory);
                        try {
                            statement.evaluate();
                        } finally {
                            try {
                                BMUnit.unloadScriptFile(testKlazz, name);
                            } catch (Exception e) {
                                fnotifier.fireTestFailure(new Failure(description, e));
                            }
                        }
                    } catch (Exception e) {
                        fnotifier.fireTestFailure(new Failure(description, e));
                    }
                }
            };
        }
    }
View Full Code Here

            // note we iterate down here because we generate statements by wraparound
            // which means the the outer statement gets executed first
            for (int i = scriptAnnotations.length; i> 0; i--) {
                BMScript scriptAnnotation= scriptAnnotations[i - 1];
                final String name = BMRunnerUtil.computeBMScriptName(scriptAnnotation.value());
                final RunNotifier fnotifier = notifier;
                final Description description = Description.createTestDescription(testKlazz, getName(), scriptAnnotation);
                final String loadDirectory = BMRunnerUtil.normaliseLoadDirectory(scriptAnnotation);
                final Statement nextStatement = result;
                result = new Statement() {
                    public void evaluate() throws Throwable {
                        try {
                            BMUnit.loadScriptFile(testKlazz, name, loadDirectory);
                            try {
                                nextStatement.evaluate();
                            } finally {
                                try {
                                    BMUnit.unloadScriptFile(testKlazz, name);
                                } catch (Exception e) {
                                    fnotifier.fireTestFailure(new Failure(description, e));
                                }
                            }
                        } catch (Exception e) {
                            fnotifier.fireTestFailure(new Failure(description, e));
                        }
                    }
                };
            }
            return result;
View Full Code Here

    {
        if (classMultiRuleAnnotation == null) {
            return statement;
        } else {
            final String scriptText = BMRunnerUtil.constructScriptText(classMultiRuleAnnotation.rules());
            final RunNotifier fnotifier = notifier;
            final Description description = Description.createTestDescription(testKlazz, getName(), classMultiRuleAnnotation);
            return new Statement() {
                public void evaluate() throws Throwable {
                    try {
                        BMUnit.loadScriptText(testKlazz, null, scriptText);
                        try {
                            statement.evaluate();
                        } finally {
                            try {
                                BMUnit.unloadScriptText(testKlazz, null);
                            } catch (Exception e) {
                                fnotifier.fireTestFailure(new Failure(description, e));
                            }
                        }
                    } catch (Exception e) {
                        fnotifier.fireTestFailure(new Failure(description, e));
                    }
                }
            };
        }
    }
View Full Code Here

    {
        if (classSingleRuleAnnotation == null) {
            return statement;
        } else {
            final String scriptText = BMRunnerUtil.constructScriptText(new BMRule[]{classSingleRuleAnnotation});
            final RunNotifier fnotifier = notifier;
            final Description description = Description.createTestDescription(testKlazz, getName(), classSingleRuleAnnotation);
            return new Statement() {
                public void evaluate() throws Throwable {
                    try {
                        BMUnit.loadScriptText(testKlazz, null, scriptText);
                        try {
                            statement.evaluate();
                        } finally {
                            try {
                                BMUnit.unloadScriptText(testKlazz, null);
                            } catch (Exception e) {
                                fnotifier.fireTestFailure(new Failure(description, e));
                            }
                        }
                    } catch (Exception e) {
                        fnotifier.fireTestFailure(new Failure(description, e));
                    }
                }
            };
        }
    }
View Full Code Here

        Build build = project.getBuild();
        return (new File(tests ? build.getTestOutputDirectory() : build.getOutputDirectory()));
    }

    public void execute() throws MojoExecutionException, MojoFailureException {
        final RunNotifier notifier = new RunNotifier();
        try {
            DefaultServer server = new DefaultServer(JspMojo.class);
            TL.set(this);
            try {
                server.run(notifier);
            } finally {
                TL.remove();
            }
        } catch (Exception e) {
            e.printStackTrace();
            throw new MojoExecutionException("Cannot compile JSP files.", e);
        } finally {
            notifier.fireTestRunFinished(new Result());
        }
    }
View Full Code Here

TOP

Related Classes of org.junit.runner.notification.RunNotifier

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.