Skip to content

Instantly share code, notes, and snippets.

@friek
Last active December 16, 2015 04:49
Show Gist options
  • Select an option

  • Save friek/5380022 to your computer and use it in GitHub Desktop.

Select an option

Save friek/5380022 to your computer and use it in GitHub Desktop.
Skip JUnit test conditionally
import static org.junit.Assert.assertTrue;
import static org.junit.Assume.assumeTrue;
import org.junit.BeforeClass;
import org.junit.Test;
public class JunitSkipTest
{
@BeforeClass
public static void setUpTest()
{
// This will make junit skip the test.
assumeTrue(false);
}
@Test
public void testSomething()
{
// Never reached, as the test got skipped.
assertTrue(true != false);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment