All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.pitest.junit.adapter.foreignclassloader.ForeignClassLoaderAdaptingRunListener Maven / Gradle / Ivy

There is a newer version: 1.16.1
Show newest version
/*
 * Copyright 2010 Henry Coles
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); 
 * you may not use this file except in compliance with the License. 
 * You may obtain a copy of the License at 
 * 
 * http://www.apache.org/licenses/LICENSE-2.0 
 * 
 * Unless required by applicable law or agreed to in writing, 
 * software distributed under the License is distributed on an "AS IS" BASIS, 
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
 * See the License for the specific language governing permissions and limitations under the License. 
 */

package org.pitest.junit.adapter.foreignclassloader;

import java.util.List;

import org.junit.runner.Description;
import org.junit.runner.notification.Failure;
import org.junit.runner.notification.RunListener;
import org.pitest.extension.ResultCollector;
import org.pitest.functional.SideEffect2;
import org.pitest.internal.IsolationUtils;

class ForeignClassLoaderAdaptingRunListener extends RunListener {

  private final List events;
  private boolean            finished = false;

  public ForeignClassLoaderAdaptingRunListener(final List queue) {
    this.events = queue;
  }

  @Override
  public void testFailure(final Failure failure) throws Exception {
    storeAsString(new Fail(failure.getException()));
    this.finished = true;
  }

  @Override
  public void testAssumptionFailure(final Failure failure) {
    // do nothing == success
  }

  @Override
  public void testIgnored(final Description description) throws Exception {
    storeAsString(new Skipped());
    this.finished = true;
  }

  @Override
  public void testStarted(final Description description) throws Exception {
    storeAsString(new Start());
  }

  @Override
  public void testFinished(final Description description) throws Exception {
    if (!this.finished) {
      storeAsString(new Success());
    }
  }

  private void storeAsString(
      final SideEffect2 result) {
    this.events.add(IsolationUtils.toXml(result));
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy