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

org.ehoffman.test.junit.GithubIssuesTestRunner Maven / Gradle / Ivy

The newest version!
package org.ehoffman.test.junit;

import org.ehoffman.test.Broken;
import org.ehoffman.test.aspects.BrokenAdvice;
import org.ehoffman.test.aspects.GitHubRestValidator;
import org.ehoffman.test.aspects.RestValidator;
import org.ehoffman.test.aspects.SkipException;
import org.junit.internal.AssumptionViolatedException;
import org.junit.runners.model.InitializationError;

/**
 * Default JUnit Runner.
 * 
 * @author rex
 */
public class GithubIssuesTestRunner extends JunitRunner {

    public GithubIssuesTestRunner(final Class klass) throws InitializationError {
        super(klass);
        final RestValidator validator = new GitHubRestValidator();
        if (validator.isConfigured()) {
            registerAnnotationHandler(Broken.class, new BrokenAdvice(false, true, validator));
        }
    }

    @Override
    public AssumptionViolatedException convertIfPossible(final Throwable t) {
        if (SkipException.class.isAssignableFrom(t.getClass())) {
            final SkipException se = (SkipException) t;
            String message;
            if (se.getReasonSkipped() != null) {
                message = se.getReasonSkipped().getClass().getSimpleName() + " has given this test a pass";
            } else {
                message = se.getMessage();
            }
            if (se.getCause() != null) {
                return new AssumptionViolatedException(message, se.getCause());
            }
            return new AssumptionViolatedException(message, se);
        }
        return null;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy