diff --git a/.gitignore b/.gitignore index 62ec7a6..505a2e9 100644 --- a/.gitignore +++ b/.gitignore @@ -6,7 +6,12 @@ build/ !**/src/test/**/build/ ### IntelliJ IDEA ### -.idea/ +!.idea/ +.idea/* +!.idea/google-java-format.xml +!.idea/codeStyles/ +.idea/codeStyles/* +!.idea/codeStyles/codeStyleConfig.xml *.iml *.ipr *.iws diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000..b9d18bf --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/.idea/google-java-format.xml b/.idea/google-java-format.xml new file mode 100644 index 0000000..8b57f45 --- /dev/null +++ b/.idea/google-java-format.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts index 4816c81..2cb9f50 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -54,6 +54,7 @@ dependencies { testImplementation(platform("org.junit:junit-bom:$junitVersion")) testImplementation("org.junit.jupiter:junit-jupiter") + implementation("io.github.hakky54:logcaptor:2.12.7") testRuntimeOnly("org.junit.platform:junit-platform-launcher") } diff --git a/config/pmd/ruleset.xml b/config/pmd/ruleset.xml index 98fd784..3b1c7fd 100644 --- a/config/pmd/ruleset.xml +++ b/config/pmd/ruleset.xml @@ -13,6 +13,8 @@ + + diff --git a/src/int-test/java/com/example/app/AppIntegrationTest.java b/src/int-test/java/com/example/app/AppIntegrationTest.java index 045b91e..270b764 100644 --- a/src/int-test/java/com/example/app/AppIntegrationTest.java +++ b/src/int-test/java/com/example/app/AppIntegrationTest.java @@ -1,13 +1,30 @@ package com.example.app; import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import nl.altindag.log.LogCaptor; import org.junit.jupiter.api.Test; class AppIntegrationTest { + private final LogCaptor logCaptor = LogCaptor.forClass(App.class); + @Test void mainRunsWithoutThrowing() { assertDoesNotThrow(() -> App.main(new String[] {})); } + + @Test + void mainLogsGreeting() { + App.main(new String[] {}); + assertEquals("Hello, world!", logCaptor.getInfoLogs().getFirst()); + } + + @Test + void mainNoErrorMessages() { + App.main(new String[] {}); + assertTrue(logCaptor.getErrorLogs().isEmpty()); + } }