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

org.nohope.test.runner.ExpectedExceptionSkippingRunner Maven / Gradle / Ivy

There is a newer version: 0.2.3
Show newest version
package org.nohope.test.runner;

import org.junit.runners.BlockJUnit4ClassRunner;
import org.junit.runners.model.FrameworkMethod;
import org.junit.runners.model.InitializationError;
import org.junit.runners.model.Statement;

/**
 * Simple {@link org.junit.runner.Runner JUnit runner} which allows to skip
 * test if particular exception type(s) was thrown by test method.
 *
 * Usage:
 * 
 *  @RunWith({@link ExpectedExceptionSkippingRunner NameAwareRunner.class})
 *  public class MyDatabaseTest {
 *
 *      @Test
 *      @{@link SkipOnException SkipOnException}(ConnectionException.class)
 *      public void testDBConnection() {
 *          ...
 *      }
 *  }
 * 
* * @author Ketoth Xupack * @since 18/01/11 05:40 PM */ public final class ExpectedExceptionSkippingRunner extends BlockJUnit4ClassRunner { /** * Runner constructor. * * @param clazz test class * @throws InitializationError on runner initialization error */ public ExpectedExceptionSkippingRunner(final Class clazz) throws InitializationError { super(clazz); } @Override protected Statement methodBlock(final FrameworkMethod method) { return new SkipStatement(super.methodBlock(method), method.getAnnotation(SkipOnException.class)); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy