org.junit.runner.notification.StoppedByUserException#org.junit.runner.notification.RunListener源码实例Demo

下面列出了org.junit.runner.notification.StoppedByUserException#org.junit.runner.notification.RunListener 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: quarkus-http   文件: DefaultServer.java
private static void runInternal(final RunNotifier notifier) {
    if (openssl && OPENSSL_FAILURE != null) {
        throw new RuntimeException(OPENSSL_FAILURE);
    }
    if (first) {
        first = false;
        undertow = Undertow.builder()
                .setHandler(rootHandler)
                .addHttpListener(getHostPort(DEFAULT), getHostAddress(DEFAULT))
                .build();
        undertow.start();
        notifier.addListener(new RunListener() {
            @Override
            public void testRunFinished(Result result) throws Exception {
                super.testRunFinished(result);
                undertow.stop();
                clientGroup.shutdownGracefully();
            }
        });
    }
}
 
源代码2 项目: buck   文件: DelegateRunNotifier.java
DelegateRunNotifier(Runner runner, RunNotifier delegate, long defaultTestTimeoutMillis) {
  this.runner = runner;
  this.delegate = delegate;
  this.finishedTests = new HashSet<Description>();
  this.defaultTestTimeoutMillis = defaultTestTimeoutMillis;
  this.timer = new Timer();
  this.hasTestThatExceededTimeout = new AtomicBoolean(false);

  // Because our fireTestRunFinished() does not seem to get invoked, we listen for the
  // delegate to fire a testRunFinished event so we can dispose of the timer.
  delegate.addListener(
      new RunListener() {
        @Override
        public void testRunFinished(Result result) {
          onTestRunFinished();
        }
      });
}
 
源代码3 项目: webtau   文件: WebTauRunner.java
@Override
protected void runChild(FrameworkMethod method, RunNotifier notifier) {
    JavaBasedTest javaBasedTest = createJavaBasedTest(method);
    WebTauTest webTauTest = javaBasedTest.getTest();

    notifier.addListener(new RunListener() {
        @Override
        public void testFailure(Failure failure) {
            webTauTest.setExceptionIfNotSet(failure.getException());
        }
    });

    beforeTestRun(javaBasedTest);
    try {
        super.runChild(method, notifier);
    } catch (Throwable e) {
        webTauTest.setExceptionIfNotSet(e);
        throw e;
    } finally {
        afterTestRun(javaBasedTest);
    }
}
 
private static void executeTestClass(Class<?> testClass) throws Throwable {

        Throwable[] throwables = new Throwable[1];
        WebTesterJUnitRunner runner = new WebTesterJUnitRunner(testClass);
        RunNotifier notifier = new RunNotifier();
        notifier.addListener(new RunListener() {

            public void testFailure(Failure failure) throws Exception {
                System.out.println("testFailure");
                throwables[0] = failure.getException();
            }

        });
        runner.run(notifier);

        if (throwables[0] != null) {
            throw throwables[0];
        }

    }
 
源代码5 项目: bazel   文件: JUnit4RunnerFactory.java
public static Factory<JUnit4Runner> create(
    Supplier<Request> requestSupplier,
    Supplier<CancellableRequestFactory> requestFactorySupplier,
    Supplier<Supplier<TestSuiteModel>> modelSupplierSupplier,
    Supplier<PrintStream> testRunnerOutSupplier,
    Supplier<JUnit4Config> configSupplier,
    Supplier<Set<RunListener>> runListenersSupplier,
    Supplier<Set<JUnit4Runner.Initializer>> initializersSupplier) {
  return new JUnit4RunnerFactory(
      requestSupplier,
      requestFactorySupplier,
      modelSupplierSupplier,
      testRunnerOutSupplier,
      configSupplier,
      runListenersSupplier,
      initializersSupplier);
}
 
源代码6 项目: phoenix   文件: RunUntilFailure.java
private void runRepeatedly(Statement statement, Description description,  
        RunNotifier notifier) {
    notifier.addListener(new RunListener() {
        @Override
        public void testFailure(Failure failure) {
            hasFailure = true;
        }
    });
    for (Description desc : description.getChildren()) {  
        if (hasFailure) {
            notifier.fireTestIgnored(desc);
        } else if(!desc.isSuite()) {
            runLeaf(statement, desc, notifier);
        }
    }  
}
 
源代码7 项目: squidb   文件: SquidbTestRunner.java
/**
 * Runs the test classes given in {@param classes}.
 *
 * @returns Zero if all tests pass, non-zero otherwise.
 */
public static int run(Class[] classes, RunListener listener, PrintStream out) {
    JUnitCore junitCore = new JUnitCore();
    junitCore.addListener(listener);
    boolean hasError = false;
    int numTests = 0;
    int numFailures = 0;
    long start = System.currentTimeMillis();
    for (@AutoreleasePool Class c : classes) {
        out.println("Running " + c.getName());
        Result result = junitCore.run(c);
        numTests += result.getRunCount();
        numFailures += result.getFailureCount();
        hasError = hasError || !result.wasSuccessful();
    }
    long end = System.currentTimeMillis();
    out.println(String.format("Ran %d tests, %d failures. Total time: %s seconds", numTests, numFailures,
            NumberFormat.getInstance().format((double) (end - start) / 1000)));
    return hasError ? 1 : 0;
}
 
源代码8 项目: android-test   文件: BundleJUnitUtilsTest.java
@Test
public void fromResult_success() throws Exception {
  Class<SampleJUnitTest> testClass = SampleJUnitTest.class;
  Description jUnitDescription = Description.createTestDescription(testClass, "sampleTest");

  Result jUnitResult = new Result();
  RunListener jUnitListener = jUnitResult.createListener();
  jUnitListener.testRunStarted(jUnitDescription);
  jUnitListener.testStarted(jUnitDescription);
  jUnitListener.testFinished(jUnitDescription);

  ParcelableResult parcelableResult =
      BundleJUnitUtils.getResult(parcelBundle(BundleJUnitUtils.getBundleFromResult(jUnitResult)));

  assertThat(parcelableResult.wasSuccessful(), is(jUnitResult.wasSuccessful()));
}
 
源代码9 项目: astor   文件: ConsoleSpammingMockitoJUnitRunner.java
@Override
public void run(RunNotifier notifier) {
    RunListener listener = new RunListener() {
        WarningsCollector warningsCollector;
        
        @Override
        public void testStarted(Description description) throws Exception {
            warningsCollector = new WarningsCollector();
        }
        
        @Override public void testFailure(Failure failure) throws Exception {                
            logger.log(warningsCollector.getWarnings());
        }
    };

    notifier.addListener(listener);

    runner.run(notifier);
}
 
源代码10 项目: astor   文件: VerboseMockitoJUnitRunner.java
@Override
public void run(RunNotifier notifier) {        

    //a listener that changes the failure's exception in a very hacky way...
    RunListener listener = new RunListener() {
        
        WarningsCollector warningsCollector;
                   
        @Override
        public void testStarted(Description description) throws Exception {
            warningsCollector = new WarningsCollector();
        }
        
        @Override 
        public void testFailure(final Failure failure) throws Exception {       
            String warnings = warningsCollector.getWarnings();
            new JUnitFailureHacker().appendWarnings(failure, warnings);                              
        }
    };

    notifier.addFirstListener(listener);

    runner.run(notifier);
}
 
源代码11 项目: astor   文件: ConsoleSpammingMockitoJUnitRunner.java
@Override
public void run(RunNotifier notifier) {
    RunListener listener = new RunListener() {
        WarningsCollector warningsCollector;
        
        @Override
        public void testStarted(Description description) throws Exception {
            warningsCollector = new WarningsCollector();
        }
        
        @Override public void testFailure(Failure failure) throws Exception {                
            logger.log(warningsCollector.getWarnings());
        }
    };

    notifier.addListener(listener);

    runner.run(notifier);
}
 
源代码12 项目: pushfish-android   文件: JUnitTestClassExecuter.java
public JUnitTestClassExecuter(ClassLoader applicationClassLoader, JUnitSpec spec, RunListener listener, TestClassExecutionListener executionListener) {
    assert executionListener instanceof ThreadSafe;
    this.applicationClassLoader = applicationClassLoader;
    this.listener = listener;
    this.options = spec;
    this.executionListener = executionListener;
}
 
源代码13 项目: pushfish-android   文件: JUnitTestClassExecuter.java
public JUnitTestClassExecuter(ClassLoader applicationClassLoader, JUnitSpec spec, RunListener listener, TestClassExecutionListener executionListener) {
    assert executionListener instanceof ThreadSafe;
    this.applicationClassLoader = applicationClassLoader;
    this.listener = listener;
    this.options = spec;
    this.executionListener = executionListener;
}
 
源代码14 项目: bazel   文件: JUnit4RunnerTest.java
@Test
public void testFailingInternationalCharsTest() throws Exception {
  config = createConfig();
  mockRunListener = mock(RunListener.class);

  JUnit4Runner runner = createRunner(SampleInternationalFailingTest.class);

  Description testDescription = Description.createTestDescription(
      SampleInternationalFailingTest.class, "testFailingInternationalCharsTest");
  Description suiteDescription = Description.createSuiteDescription(
      SampleInternationalFailingTest.class);
  suiteDescription.addChild(testDescription);

  Result result = runner.run();

  assertThat(result.getRunCount()).isEqualTo(1);
  assertThat(result.getFailureCount()).isEqualTo(1);
  assertThat(result.getIgnoreCount()).isEqualTo(0);

  String output = new String(stdoutByteStream.toByteArray(), StandardCharsets.UTF_8);
  // Intentionally swapped "Test 日\u672C." / "Test \u65E5本." to make sure that the "raw"
  // character does not get corrupted (would become ? in both cases and we would not notice).
  assertThat(output).contains("expected:<Test [Japan].> but was:<Test [日\u672C].>");

  InOrder inOrder = inOrder(mockRunListener);

  inOrder.verify(mockRunListener).testRunStarted(any(Description.class));
  inOrder.verify(mockRunListener).testStarted(any(Description.class));
  inOrder.verify(mockRunListener).testFailure(any(Failure.class));
  inOrder.verify(mockRunListener).testFinished(any(Description.class));
  inOrder.verify(mockRunListener).testRunFinished(any(Result.class));
}
 
源代码15 项目: COLA   文件: ColaNotifier.java
/**
 * 方法级结束
 * @param testMethod
 * @param description
 */
public void fireTestFinished(Method testMethod, Description description){
    Description methodDescription = getMethodDescription(testMethod, description);
    for (RunListener listener : listeners) {
        try {
            listener.testFinished(methodDescription);
        } catch (Exception e) {
            logger.error("", e);
        }
    }
}
 
@Override
public void run(RunNotifier notifier)
{
  RunListener l = new RunListener()
  {
    public void testRunFinished(Result result) throws Exception
    {
      super.testRunFinished(result);
      GitCommitOrRevert.doCommitOrRevert(result.getFailureCount());
    }
  };
  notifier.addListener(l);
  super.run(notifier);
}
 
源代码17 项目: marathonv5   文件: MarathonTestRunner.java
/**
 * Do not use. Testing purposes only.
 */
public Result run(org.junit.runner.Runner runner) {
    Result result = new Result();
    RunListener listener = result.createListener();
    notifier.addFirstListener(listener);
    try {
        notifier.fireTestRunStarted(runner.getDescription());
        runner.run(notifier);
        notifier.fireTestRunFinished(result);
    } finally {
        removeListener(listener);
    }
    return result;
}
 
源代码18 项目: jpa-unit   文件: JpaUnitRuleTest.java
@Test
public void testClassWithPersistenceContextWithKonfiguredUnitNameSpecified() throws Exception {
    // GIVEN
    final JCodeModel jCodeModel = new JCodeModel();
    final JPackage jp = jCodeModel.rootPackage();
    final JDefinedClass jClass = jp._class(JMod.PUBLIC, "ClassUnderTest");
    final JFieldVar ruleField = jClass.field(JMod.PUBLIC, JpaUnitRule.class, "rule");
    ruleField.annotate(Rule.class);
    final JInvocation instance = JExpr._new(jCodeModel.ref(JpaUnitRule.class)).arg(JExpr.direct("getClass()"));
    ruleField.init(instance);
    final JFieldVar emField = jClass.field(JMod.PRIVATE, EntityManager.class, "em");
    final JAnnotationUse jAnnotation = emField.annotate(PersistenceContext.class);
    jAnnotation.param("unitName", "test-unit-1");
    final JMethod jMethod = jClass.method(JMod.PUBLIC, jCodeModel.VOID, "testMethod");
    jMethod.annotate(Test.class);

    buildModel(testFolder.getRoot(), jCodeModel);
    compileModel(testFolder.getRoot());

    final Class<?> cut = loadClass(testFolder.getRoot(), jClass.name());
    final BlockJUnit4ClassRunner runner = new BlockJUnit4ClassRunner(cut);

    final RunListener listener = mock(RunListener.class);
    final RunNotifier notifier = new RunNotifier();
    notifier.addListener(listener);

    // WHEN
    runner.run(notifier);

    // THEN
    final ArgumentCaptor<Description> descriptionCaptor = ArgumentCaptor.forClass(Description.class);
    verify(listener).testStarted(descriptionCaptor.capture());
    assertThat(descriptionCaptor.getValue().getClassName(), equalTo("ClassUnderTest"));
    assertThat(descriptionCaptor.getValue().getMethodName(), equalTo("testMethod"));

    verify(listener).testFinished(descriptionCaptor.capture());
    assertThat(descriptionCaptor.getValue().getClassName(), equalTo("ClassUnderTest"));
    assertThat(descriptionCaptor.getValue().getMethodName(), equalTo("testMethod"));
}
 
源代码19 项目: jpa-unit   文件: JpaUnitRuleTest.java
@Test
public void testClassWithPersistenceUnitWithKonfiguredUnitNameSpecified() throws Exception {
    // GIVEN
    final JCodeModel jCodeModel = new JCodeModel();
    final JPackage jp = jCodeModel.rootPackage();
    final JDefinedClass jClass = jp._class(JMod.PUBLIC, "ClassUnderTest");
    final JFieldVar ruleField = jClass.field(JMod.PUBLIC, JpaUnitRule.class, "rule");
    ruleField.annotate(Rule.class);
    final JInvocation instance = JExpr._new(jCodeModel.ref(JpaUnitRule.class)).arg(JExpr.direct("getClass()"));
    ruleField.init(instance);
    final JFieldVar emField = jClass.field(JMod.PRIVATE, EntityManagerFactory.class, "emf");
    final JAnnotationUse jAnnotation = emField.annotate(PersistenceUnit.class);
    jAnnotation.param("unitName", "test-unit-1");
    final JMethod jMethod = jClass.method(JMod.PUBLIC, jCodeModel.VOID, "testMethod");
    jMethod.annotate(Test.class);

    buildModel(testFolder.getRoot(), jCodeModel);
    compileModel(testFolder.getRoot());

    final Class<?> cut = loadClass(testFolder.getRoot(), jClass.name());
    final BlockJUnit4ClassRunner runner = new BlockJUnit4ClassRunner(cut);

    final RunListener listener = mock(RunListener.class);
    final RunNotifier notifier = new RunNotifier();
    notifier.addListener(listener);

    // WHEN
    runner.run(notifier);

    // THEN
    final ArgumentCaptor<Description> descriptionCaptor = ArgumentCaptor.forClass(Description.class);
    verify(listener).testStarted(descriptionCaptor.capture());
    assertThat(descriptionCaptor.getValue().getClassName(), equalTo("ClassUnderTest"));
    assertThat(descriptionCaptor.getValue().getMethodName(), equalTo("testMethod"));

    verify(listener).testFinished(descriptionCaptor.capture());
    assertThat(descriptionCaptor.getValue().getClassName(), equalTo("ClassUnderTest"));
    assertThat(descriptionCaptor.getValue().getMethodName(), equalTo("testMethod"));
}
 
源代码20 项目: jpa-unit   文件: JpaUnitRunnerTest.java
@Test
public void testClassWithMultiplePersistenceContextFields() throws Exception {
    // GIVEN
    final JCodeModel jCodeModel = new JCodeModel();
    final JPackage jp = jCodeModel.rootPackage();
    final JDefinedClass jClass = jp._class(JMod.PUBLIC, "ClassUnderTest");
    final JAnnotationUse jAnnotationUse = jClass.annotate(RunWith.class);
    jAnnotationUse.param("value", JpaUnitRunner.class);
    final JFieldVar em1Field = jClass.field(JMod.PRIVATE, EntityManager.class, "em1");
    em1Field.annotate(PersistenceContext.class);
    final JFieldVar em2Field = jClass.field(JMod.PRIVATE, EntityManager.class, "em2");
    em2Field.annotate(PersistenceContext.class);
    final JMethod jMethod = jClass.method(JMod.PUBLIC, jCodeModel.VOID, "testMethod");
    jMethod.annotate(Test.class);

    buildModel(testFolder.getRoot(), jCodeModel);
    compileModel(testFolder.getRoot());

    final Class<?> cut = loadClass(testFolder.getRoot(), jClass.name());

    final RunListener listener = mock(RunListener.class);
    final RunNotifier notifier = new RunNotifier();
    notifier.addListener(listener);

    final JpaUnitRunner runner = new JpaUnitRunner(cut);

    // WHEN
    runner.run(notifier);

    // THEN
    final ArgumentCaptor<Failure> failureCaptor = ArgumentCaptor.forClass(Failure.class);
    verify(listener).testFailure(failureCaptor.capture());

    final Failure failure = failureCaptor.getValue();
    assertThat(failure.getException().getClass(), equalTo(IllegalArgumentException.class));
    assertThat(failure.getException().getMessage(), containsString("Only single field is allowed"));
}
 
源代码21 项目: jpa-unit   文件: JpaUnitRunnerTest.java
@Test
public void testClassWithMultiplePersistenceUnitFields() throws Exception {
    // GIVEN
    final JCodeModel jCodeModel = new JCodeModel();
    final JPackage jp = jCodeModel.rootPackage();
    final JDefinedClass jClass = jp._class(JMod.PUBLIC, "ClassUnderTest");
    final JAnnotationUse jAnnotationUse = jClass.annotate(RunWith.class);
    jAnnotationUse.param("value", JpaUnitRunner.class);
    final JFieldVar emf1Field = jClass.field(JMod.PRIVATE, EntityManagerFactory.class, "emf1");
    emf1Field.annotate(PersistenceUnit.class);
    final JFieldVar emf2Field = jClass.field(JMod.PRIVATE, EntityManagerFactory.class, "emf2");
    emf2Field.annotate(PersistenceUnit.class);
    final JMethod jMethod = jClass.method(JMod.PUBLIC, jCodeModel.VOID, "testMethod");
    jMethod.annotate(Test.class);

    buildModel(testFolder.getRoot(), jCodeModel);
    compileModel(testFolder.getRoot());

    final Class<?> cut = loadClass(testFolder.getRoot(), jClass.name());

    final RunListener listener = mock(RunListener.class);
    final RunNotifier notifier = new RunNotifier();
    notifier.addListener(listener);

    final JpaUnitRunner runner = new JpaUnitRunner(cut);

    // WHEN
    runner.run(notifier);

    // THEN
    final ArgumentCaptor<Failure> failureCaptor = ArgumentCaptor.forClass(Failure.class);
    verify(listener).testFailure(failureCaptor.capture());

    final Failure failure = failureCaptor.getValue();
    assertThat(failure.getException().getClass(), equalTo(IllegalArgumentException.class));
    assertThat(failure.getException().getMessage(), containsString("Only single field is allowed"));
}
 
源代码22 项目: jpa-unit   文件: JpaUnitRunnerTest.java
@Test
public void testClassWithPersistenceContextAndPersistenceUnitFields() throws Exception {
    // GIVEN
    final JCodeModel jCodeModel = new JCodeModel();
    final JPackage jp = jCodeModel.rootPackage();
    final JDefinedClass jClass = jp._class(JMod.PUBLIC, "ClassUnderTest");
    final JAnnotationUse jAnnotationUse = jClass.annotate(RunWith.class);
    jAnnotationUse.param("value", JpaUnitRunner.class);
    final JFieldVar emf1Field = jClass.field(JMod.PRIVATE, EntityManager.class, "em");
    emf1Field.annotate(PersistenceContext.class);
    final JFieldVar emf2Field = jClass.field(JMod.PRIVATE, EntityManagerFactory.class, "emf");
    emf2Field.annotate(PersistenceUnit.class);
    final JMethod jMethod = jClass.method(JMod.PUBLIC, jCodeModel.VOID, "testMethod");
    jMethod.annotate(Test.class);

    buildModel(testFolder.getRoot(), jCodeModel);
    compileModel(testFolder.getRoot());

    final Class<?> cut = loadClass(testFolder.getRoot(), jClass.name());

    final RunListener listener = mock(RunListener.class);
    final RunNotifier notifier = new RunNotifier();
    notifier.addListener(listener);

    final JpaUnitRunner runner = new JpaUnitRunner(cut);

    // WHEN
    runner.run(notifier);

    // THEN
    final ArgumentCaptor<Failure> failureCaptor = ArgumentCaptor.forClass(Failure.class);
    verify(listener).testFailure(failureCaptor.capture());

    final Failure failure = failureCaptor.getValue();
    assertThat(failure.getException().getClass(), equalTo(IllegalArgumentException.class));
    assertThat(failure.getException().getMessage(), containsString("either @PersistenceUnit or @PersistenceContext"));
}
 
源代码23 项目: jpa-unit   文件: JpaUnitRunnerTest.java
@Test
public void testClassWithPersistenceUnitFieldOfWrongType() throws Exception {
    // GIVEN
    final JCodeModel jCodeModel = new JCodeModel();
    final JPackage jp = jCodeModel.rootPackage();
    final JDefinedClass jClass = jp._class(JMod.PUBLIC, "ClassUnderTest");
    final JAnnotationUse jAnnotationUse = jClass.annotate(RunWith.class);
    jAnnotationUse.param("value", JpaUnitRunner.class);
    final JFieldVar emField = jClass.field(JMod.PRIVATE, EntityManager.class, "emf");
    emField.annotate(PersistenceUnit.class);
    final JMethod jMethod = jClass.method(JMod.PUBLIC, jCodeModel.VOID, "testMethod");
    jMethod.annotate(Test.class);

    buildModel(testFolder.getRoot(), jCodeModel);
    compileModel(testFolder.getRoot());

    final Class<?> cut = loadClass(testFolder.getRoot(), jClass.name());

    final RunListener listener = mock(RunListener.class);
    final RunNotifier notifier = new RunNotifier();
    notifier.addListener(listener);

    final JpaUnitRunner runner = new JpaUnitRunner(cut);

    // WHEN
    runner.run(notifier);

    // THEN
    final ArgumentCaptor<Failure> failureCaptor = ArgumentCaptor.forClass(Failure.class);
    verify(listener).testFailure(failureCaptor.capture());

    final Failure failure = failureCaptor.getValue();
    assertThat(failure.getException().getClass(), equalTo(IllegalArgumentException.class));
    assertThat(failure.getException().getMessage(),
            containsString("annotated with @PersistenceUnit is not of type EntityManagerFactory"));
}
 
源代码24 项目: jpa-unit   文件: JpaUnitRunnerTest.java
@Test
public void testClassWithPersistenceContextWithoutUnitNameSpecified() throws Exception {
    // GIVEN
    final JCodeModel jCodeModel = new JCodeModel();
    final JPackage jp = jCodeModel.rootPackage();
    final JDefinedClass jClass = jp._class(JMod.PUBLIC, "ClassUnderTest");
    final JAnnotationUse jAnnotationUse = jClass.annotate(RunWith.class);
    jAnnotationUse.param("value", JpaUnitRunner.class);
    final JFieldVar emField = jClass.field(JMod.PRIVATE, EntityManager.class, "em");
    emField.annotate(PersistenceContext.class);
    final JMethod jMethod = jClass.method(JMod.PUBLIC, jCodeModel.VOID, "testMethod");
    jMethod.annotate(Test.class);

    buildModel(testFolder.getRoot(), jCodeModel);
    compileModel(testFolder.getRoot());

    final Class<?> cut = loadClass(testFolder.getRoot(), jClass.name());

    final RunListener listener = mock(RunListener.class);
    final RunNotifier notifier = new RunNotifier();
    notifier.addListener(listener);

    final JpaUnitRunner runner = new JpaUnitRunner(cut);

    // WHEN
    runner.run(notifier);

    // THEN
    final ArgumentCaptor<Failure> failureCaptor = ArgumentCaptor.forClass(Failure.class);
    verify(listener).testFailure(failureCaptor.capture());

    final Failure failure = failureCaptor.getValue();
    assertThat(failure.getException().getClass(), equalTo(JpaUnitException.class));
    assertThat(failure.getException().getMessage(), containsString("No Persistence"));
}
 
源代码25 项目: kurento-java   文件: KurentoRunNotifier.java
void run() {
  for (RunListener listener : currentListeners) {
    try {
      notifyListener(listener);
    } catch (Exception e) {
      exception = e;
      break;
    }
  }
}
 
源代码26 项目: RDFUnit   文件: RunnerOnIgnoredClassTest.java
@Test
public void verifyTestRunnerIsNotExecuted() throws Exception {
    RunNotifier notifier = new RunNotifier();
    RunListener listener = mock(RunListener.class);
    notifier.addListener(listener);

    Request.aClass(TestRunnerIgnoredOnClassLevel.class).getRunner().run(notifier);

    verify(listener, times(1)).testIgnored(any(Description.class));

    Assertions.assertThat(TestRunnerIgnoredOnClassLevel.ignoredTestInputMethodNotCalled).isTrue();
}
 
源代码27 项目: jpa-unit   文件: JpaUnitRunnerTest.java
@Test
public void testClassWithPersistenceUnitWithKonfiguredUnitNameSpecified() throws Exception {
    // GIVEN
    final JCodeModel jCodeModel = new JCodeModel();
    final JPackage jp = jCodeModel.rootPackage();
    final JDefinedClass jClass = jp._class(JMod.PUBLIC, "ClassUnderTest");
    final JAnnotationUse jAnnotationUse = jClass.annotate(RunWith.class);
    jAnnotationUse.param("value", JpaUnitRunner.class);
    final JFieldVar emField = jClass.field(JMod.PRIVATE, EntityManagerFactory.class, "emf");
    final JAnnotationUse jAnnotation = emField.annotate(PersistenceUnit.class);
    jAnnotation.param("unitName", "test-unit-1");
    final JMethod jMethod = jClass.method(JMod.PUBLIC, jCodeModel.VOID, "testMethod");
    jMethod.annotate(Test.class);

    buildModel(testFolder.getRoot(), jCodeModel);
    compileModel(testFolder.getRoot());

    final Class<?> cut = loadClass(testFolder.getRoot(), jClass.name());
    final JpaUnitRunner runner = new JpaUnitRunner(cut);

    final RunListener listener = mock(RunListener.class);
    final RunNotifier notifier = new RunNotifier();
    notifier.addListener(listener);

    // WHEN
    runner.run(notifier);

    // THEN
    final ArgumentCaptor<Description> descriptionCaptor = ArgumentCaptor.forClass(Description.class);
    verify(listener).testStarted(descriptionCaptor.capture());
    assertThat(descriptionCaptor.getValue().getClassName(), equalTo("ClassUnderTest"));
    assertThat(descriptionCaptor.getValue().getMethodName(), equalTo("testMethod"));

    verify(listener).testFinished(descriptionCaptor.capture());
    assertThat(descriptionCaptor.getValue().getClassName(), equalTo("ClassUnderTest"));
    assertThat(descriptionCaptor.getValue().getMethodName(), equalTo("testMethod"));
}
 
源代码28 项目: kurento-java   文件: KurentoRunNotifier.java
@Override
public void fireTestFinished(final Description description) {
  new SafeNotifier() {
    @Override
    protected void notifyListener(RunListener each) throws Exception {
      each.testFinished(description);
      exception = null;
    }
  }.run();
}
 
源代码29 项目: bazel   文件: JUnit4RunnerTest.java
@Test
public void testPassingTest() throws Exception {
  config = createConfig();
  mockRunListener = mock(RunListener.class);

  JUnit4Runner runner = createRunner(SamplePassingTest.class);

  Description testDescription =
      Description.createTestDescription(SamplePassingTest.class, "testThatAlwaysPasses");
  Description suiteDescription =
      Description.createSuiteDescription(SamplePassingTest.class);
  suiteDescription.addChild(testDescription);

  Result result = runner.run();

  assertThat(result.getRunCount()).isEqualTo(1);
  assertThat(result.getFailureCount()).isEqualTo(0);
  assertThat(result.getIgnoreCount()).isEqualTo(0);

  assertPassingTestHasExpectedOutput(stdoutByteStream, SamplePassingTest.class);

  InOrder inOrder = inOrder(mockRunListener);

  inOrder.verify(mockRunListener).testRunStarted(suiteDescription);
  inOrder.verify(mockRunListener).testStarted(testDescription);
  inOrder.verify(mockRunListener).testFinished(testDescription);
  inOrder.verify(mockRunListener).testRunFinished(any(Result.class));
}
 
源代码30 项目: nopol   文件: TestSuiteExecution.java
public static CompoundResult runTestResult(Collection<TestResult> testCases, ClassLoader classLoaderForTestThread, RunListener listener, NopolContext nopolContext) {
    List<Result> results = MetaList.newArrayList(testCases.size());
    for (TestResult testCase : testCases) {
        if (testCase.getTestCase().className().startsWith("junit.")) {
            continue;
        }
        String completeTestName = testCase.getTestCase().className()+"#"+testCase.getTestCase().testName();
        if (!nopolContext.getTestMethodsToIgnore().contains(completeTestName)) {
            results.add(runTestCase(testCase, classLoaderForTestThread, listener, nopolContext));
        }
    }
    return new CompoundResult(results);
}