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
| <plugin> | |
| <groupId>org.apache.maven.plugins</groupId> | |
| <artifactId>maven-surefire-plugin</artifactId> | |
| <version>2.22.0</version> | |
| </plugin> |
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
| <plugin> | |
| <groupId>org.apache.maven.plugins</groupId> | |
| <artifactId>maven-surefire-plugin</artifactId> | |
| <version>2.22.0</version> | |
| <configuration> | |
| <groups>includeTag</groups> | |
| <excludedGroups>excludeTag</excludedGroups> | |
| </configuration> | |
| </plugin> |
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
| <plugin> | |
| <groupId>org.apache.maven.plugins</groupId> | |
| <artifactId>maven-surefire-plugin</artifactId> | |
| <version>2.21.0</version> | |
| <configuration> | |
| <properties> | |
| <excludeTags>excludeTag</excludeTags> | |
| <includeTags>includeTag</includeTags> | |
| </properties> | |
| </configuration> |
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
| @ExtendWith(MockitoExtension.class) | |
| public class TestMockitoInjection { | |
| private BoringService service; | |
| public TestMockitoInjection(@Mock BoringService service) { | |
| this.service = service; | |
| } | |
| @Test | |
| public void testConstructorInjectedValue() { |
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
| public class TestAssertJSoftAssertions { | |
| @Test | |
| public void testSoftAssertions() { | |
| Person person = new Person("John", "Doe"); | |
| SoftAssertions softly = new SoftAssertions(); | |
| softly.assertThat(person.getFName()).isEqualTo("Anonymous"); | |
| softly.assertThat(person.getLName()).isEqualTo("Person"); | |
| softly.assertAll(); | |
| } |
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
| public class ConsoleOutputListener implements TestExecutionListener { | |
| @Override | |
| public void reportingEntryPublished(TestIdentifier testIdentifier, ReportEntry entry) { | |
| entry.getKeyValuePairs().values().stream().forEach(c -> System.out.println("Captured output: " + c)); | |
| TestExecutionListener.super.reportingEntryPublished(testIdentifier, entry); | |
| } | |
| } |
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
| <plugin> | |
| <groupId>org.apache.maven.plugins</groupId> | |
| <artifactId>maven-surefire-plugin</artifactId> | |
| <version>2.22.0</version> | |
| <configuration> | |
| <properties> | |
| <configurationParameters> | |
| junit.platform.output.capture.stdout=true | |
| junit.platform.output.capture.stderr=true | |
| </configurationParameters> |
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
| <!-- New aggregate dependency --> | |
| <dependency> | |
| <groupId>org.junit.jupiter</groupId> | |
| <artifactId>junit-jupiter</artifactId> | |
| <scope>test</scope> | |
| </dependency> | |
| <!-- Old dependencies --> | |
| <!-- <dependency> --> | |
| <!-- <groupId>org.junit.jupiter</groupId> --> | |
| <!-- <artifactId>junit-jupiter-api</artifactId> --> |
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
| @ContextConfiguration(classes = { HotelApplication.class }, initializers = ITCustomerJUnit5Repo.Initializer.class) | |
| @DirtiesContext(classMode = ClassMode.BEFORE_EACH_TEST_METHOD) | |
| @TestMethodOrder(OrderAnnotation.class) | |
| public class ITCustomerJUnit5Repo { | |
| //Removed code, for clarity | |
| @Test | |
| @Order(1) | |
| public void testCountNumberOfCustomersInDB() { |
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
| @TestMethodOrder(OrderAnnotation.class) | |
| public class TestTempDir { | |
| @Test | |
| @Order(1) | |
| public void workInMethod(@TempDir Path tempPathArg) throws IOException { | |
| File temp = tempPathArg.resolve("temp.txt").toFile(); | |
| FileUtils.write(temp, "temp contents", StandardCharsets.ISO_8859_1); | |
| assertEquals("temp contents", FileUtils.readFileToString(temp, StandardCharsets.ISO_8859_1)); |