Merge branch 'masterupstream' into beforeAfterAnnotationsJunit

This commit is contained in:
Marcos Lopez Gonzalez
2018-04-10 22:17:26 +02:00
115 changed files with 2124 additions and 301 deletions
@@ -0,0 +1,23 @@
package com.baeldung.exception;
import static org.junit.jupiter.api.Assertions.assertThrows;
import org.junit.jupiter.api.Test;
public class ExceptionAssertionTest {
@Test
public void whenExceptionThrown_thenAssertionSucceeds() {
String test = null;
assertThrows(NullPointerException.class, () -> {
test.length();
});
}
@Test
public void whenDerivedExceptionThrown_thenAssertionSucceds() {
String test = null;
assertThrows(RuntimeException.class, () -> {
test.length();
});
}
}
@@ -0,0 +1,24 @@
package com.baeldung.migration.junit4;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
public class ExceptionAssertionTest {
@Rule
public ExpectedException exceptionRule = ExpectedException.none();
@Test(expected = NullPointerException.class)
public void whenExceptionThrown_thenExpectationSatisfied() {
String test = null;
test.length();
}
@Test
public void whenExceptionThrown_thenRuleIsApplied() {
exceptionRule.expect(NumberFormatException.class);
exceptionRule.expectMessage("For input string");
Integer.parseInt("1a");
}
}
@@ -54,11 +54,11 @@ public class HamcrestFileUnitTest {
assertThat(file, aFileWithSize(greaterThan(1L)));;
}
@Test
/*@Test
public final void whenVerifyingFilePath_thenCorrect() {
File file = new File("src/test/resources/test1.in");
assertThat(file, aFileWithCanonicalPath(containsString("src/test/resources")));
assertThat(file, aFileWithAbsolutePath(containsString("src/test/resources")));
}
}*/
}
@@ -38,7 +38,7 @@ public class AssertJConditionUnitTest {
assertThat(member).has(nameJohn);
fail();
} catch (AssertionError e) {
assertThat(e).hasMessageContaining("to have:\n <name John>");
assertThat(e).hasMessageContaining("<name John>");
}
}