Java Code Examples for org.junit.runner.notification.RunListener#testRunStarted()

The following examples show how to use org.junit.runner.notification.RunListener#testRunStarted() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BundleJUnitUtilsTest.java    From android-test with Apache License 2.0 7 votes vote down vote up
@Test
public void fromResult_failure() throws Exception {
  Class<SampleJUnitTest> testClass = SampleJUnitTest.class;
  Description jUnitDescription = Description.createTestDescription(testClass, "sampleTest");
  Throwable throwable = new RuntimeException("Your test is bad and you should feel bad.");
  Failure jUnitFailure = new Failure(jUnitDescription, throwable);

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

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

  assertThat(parcelableResult.wasSuccessful(), is(jUnitResult.wasSuccessful()));
  assertThat(parcelableResult.getFailureCount(), is(jUnitResult.getFailureCount()));
  compareFailure(parcelableResult.getFailures().get(0), jUnitResult.getFailures().get(0));
}
 
Example 2
Source File: BundleJUnitUtilsTest.java    From android-test with Apache License 2.0 6 votes vote down vote up
@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()));
}
 
Example 3
Source File: ColaNotifier.java    From COLA with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * runner开始
 * @param colaDes
 */
public void fireTestRunStarted(final ColaTestDescription colaDes){
    if(colaRunListener != null){
        colaRunListener.testRunStarted(colaDes);
    }

    for (RunListener listener : listeners) {
        try {
            listener.testRunStarted(colaDes.getDescription());
        } catch (Exception e) {
            logger.error("", e);
        }
    }
}
 
Example 4
Source File: OrchestratedInstrumentationListenerTest.java    From android-test with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() throws Exception {
  MockitoAnnotations.initMocks(this);
  listener = new OrchestratedInstrumentationListener(this);
  listener.odoCallback = mockCallback;

  Class<SampleJUnitTest> testClass = SampleJUnitTest.class;
  jUnitDescription = Description.createTestDescription(testClass, "sampleTest");
  jUnitFailure = new Failure(jUnitDescription, new Throwable("error"));
  jUnitResult = new Result();
  RunListener jUnitListener = jUnitResult.createListener();
  jUnitListener.testRunStarted(jUnitDescription);
  jUnitListener.testStarted(jUnitDescription);
  jUnitListener.testFinished(jUnitDescription);
}