Created
January 11, 2017 14:54
-
-
Save thieux/3ee2b97f0e5643bd0a357a1bca67b9cf to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package fr.ing.authorization.engine; | |
import org.junit.Assume; | |
import org.junit.Ignore; | |
import org.junit.Test; | |
import static org.junit.Assert.assertEquals; | |
import static org.junit.Assert.assertTrue; | |
import static org.junit.Assert.fail; | |
public class CheckTest { | |
@Test | |
public void unexpectedError() throws Exception { | |
// Reported as an exception | |
throw new Exception("yoo"); | |
} | |
@Test | |
public void possibleFailure() { | |
try { | |
throw new Exception("yoo"); | |
} catch (Exception e) { | |
// Throws java.lang.AssertionError. | |
// Reported as a failure. | |
fail(e.getLocalizedMessage()); | |
} | |
} | |
@Test | |
public void expectedVersusActual() { | |
// Throws java.lang.AssertionError. | |
// Reported as a failure. | |
assertEquals(1, 2); | |
} | |
@Test | |
public void ignoreTestGivenFalseAssumption() { | |
String x = null; | |
// Throws AssumptionViolatedException extends RuntimeException. | |
// *NOT* reported (ignored). | |
// *NOT* a failure. | |
Assume.assumeTrue(x != null); | |
// Can't even reach the check that matters | |
assertTrue(x.equals(x)); | |
} | |
@Test | |
@Ignore | |
public void ignored() { | |
// *NOT* reported (ignored). | |
assertEquals(1, 2); | |
} | |
@Test | |
public void falseAssertion() { | |
String x = null; | |
// Throws java.lang.AssertionError on if `java -ea` | |
// Reported as a failure. | |
assert x != null; | |
assertTrue(x.equals(x)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment