diff --git a/core/src/test/java/com/cosium/code/format/AbstractMavenModuleTest.java b/core/src/test/java/com/cosium/code/format/AbstractMavenModuleTest.java index 21812737..3724f670 100644 --- a/core/src/test/java/com/cosium/code/format/AbstractMavenModuleTest.java +++ b/core/src/test/java/com/cosium/code/format/AbstractMavenModuleTest.java @@ -6,6 +6,7 @@ import io.takari.maven.testing.executor.MavenRuntime; import io.takari.maven.testing.executor.junit.MavenPluginTest; import java.nio.file.Paths; +import org.junit.jupiter.api.DisplayName; /** * @author Réda Housni Alaoui @@ -27,8 +28,9 @@ public AbstractMavenModuleTest( } @MavenPluginTest - public void GIVEN_bad_formatted_files_WHEN_format_code_THEN_all_files_should_have_correct_format() - throws Exception { + @DisplayName( + "GIVEN bad formatted files WHEN format code THEN all files should have correct format") + public void test1() throws Exception { mavenExecution() .withCliOptions(goalCliOption("validate-code-format")) .execute() @@ -45,9 +47,9 @@ public void GIVEN_bad_formatted_files_WHEN_format_code_THEN_all_files_should_hav } @MavenPluginTest - public void - GIVEN_bad_formatted_file_WHEN_validating_THEN_the_command_formatting_all_files_is_displayed() - throws Exception { + @DisplayName( + "GIVEN bad formatted file WHEN validating THEN the command formatting all files is displayed") + public void test2() throws Exception { mavenExecution() .withCliOptions(goalCliOption("validate-code-format")) .execute() @@ -55,9 +57,9 @@ public void GIVEN_bad_formatted_files_WHEN_format_code_THEN_all_files_should_hav } @MavenPluginTest - public void - GIVEN_bad_formatted_file_WHEN_adding_and_committing_it_THEN_it_should_have_correct_format() - throws Exception { + @DisplayName( + "GIVEN bad formatted file WHEN adding and committing it THEN it should have correct format") + public void test3() throws Exception { mavenExecution() .withCliOptions(goalCliOption("validate-code-format")) .execute() @@ -84,9 +86,9 @@ public void GIVEN_bad_formatted_files_WHEN_format_code_THEN_all_files_should_hav } @MavenPluginTest - public void - GIVEN_bad_formatted_generated_file_WHEN_formatting_THEN_generated_file_should_be_skipped() - throws Exception { + @DisplayName( + "GIVEN bad formatted generated file WHEN formatting THEN generated file should be skipped") + public void test4() throws Exception { String generatedSourceFile = Paths.get(mavenModuleDirectory) .resolve("target/generated-sources/GeneratedBadFormat.java") @@ -100,9 +102,10 @@ public void GIVEN_bad_formatted_files_WHEN_format_code_THEN_all_files_should_hav } @MavenPluginTest - public void - GIVEN_bad_formatted_files_WHEN_format_code_with_aosp_enabled_THEN_all_files_should_be_formatted_according_to_aosp() - throws Exception { + @DisplayName( + "GIVEN bad formatted files WHEN format code with aosp enabled THEN all files should be" + + " formatted according to aosp") + public void test5() throws Exception { mavenExecution() .withCliOptions(goalCliOption("validate-code-format"), "-Daosp=true") .execute() @@ -125,8 +128,8 @@ public void GIVEN_bad_formatted_files_WHEN_format_code_THEN_all_files_should_hav } @MavenPluginTest - public void GIVEN_bad_formatted_file_WHEN_committing_all_THEN_it_should_have_correct_format() - throws Exception { + @DisplayName("GIVEN bad formatted file WHEN committing all THEN it should have correct format") + public void test6() throws Exception { mavenExecution() .withCliOptions(goalCliOption("validate-code-format")) .execute() diff --git a/core/src/test/java/com/cosium/code/format/AutoCrlfFileTest.java b/core/src/test/java/com/cosium/code/format/AutoCrlfFileTest.java index 7ad654c0..a7ff18f1 100644 --- a/core/src/test/java/com/cosium/code/format/AutoCrlfFileTest.java +++ b/core/src/test/java/com/cosium/code/format/AutoCrlfFileTest.java @@ -13,6 +13,7 @@ import org.eclipse.jgit.lib.StoredConfig; import org.eclipse.jgit.revwalk.RevWalk; import org.eclipse.jgit.treewalk.TreeWalk; +import org.junit.jupiter.api.DisplayName; /** * Covers issue 227. @@ -38,8 +39,9 @@ public AutoCrlfFileTest(MavenRuntime.MavenRuntimeBuilder mavenBuilder) throws Ex } @MavenPluginTest - public void GIVEN_auto_crlf_WHEN_committing_a_badly_formatted_file_THEN_it_is_not_left_modified() - throws Exception { + @DisplayName( + "GIVEN auto crlf WHEN committing a badly formatted file THEN it is not left modified") + public void test1() throws Exception { enableAutoCrlf(); commitBaseline(); diff --git a/core/src/test/java/com/cosium/code/format/EmptyCommitTest.java b/core/src/test/java/com/cosium/code/format/EmptyCommitTest.java index 842bcf26..c3f711b6 100644 --- a/core/src/test/java/com/cosium/code/format/EmptyCommitTest.java +++ b/core/src/test/java/com/cosium/code/format/EmptyCommitTest.java @@ -13,6 +13,7 @@ import org.eclipse.jgit.api.MergeResult.MergeStatus; import org.eclipse.jgit.api.errors.AbortedByHookException; import org.eclipse.jgit.lib.ObjectId; +import org.junit.jupiter.api.DisplayName; /** * Covers issue 96. @@ -48,9 +49,10 @@ public EmptyCommitTest(MavenRuntime.MavenRuntimeBuilder mavenBuilder) throws Exc } @MavenPluginTest - public void - GIVEN_default_options_WHEN_the_formatting_reverts_the_staged_change_THEN_git_creates_an_empty_commit() - throws Exception { + @DisplayName( + "GIVEN default options WHEN the formatting reverts the staged change THEN git creates an" + + " empty commit") + public void test1() throws Exception { commitBaseline(); installHooks(DO_NOT_FAIL_ON_EMPTY_COMMIT); @@ -63,9 +65,10 @@ public EmptyCommitTest(MavenRuntime.MavenRuntimeBuilder mavenBuilder) throws Exc } @MavenPluginTest - public void - GIVEN_fail_on_empty_commit_WHEN_the_formatting_reverts_the_staged_change_THEN_the_commit_is_refused() - throws Exception { + @DisplayName( + "GIVEN fail on empty commit WHEN the formatting reverts the staged change THEN the commit is" + + " refused") + public void test2() throws Exception { commitBaseline(); installHooks(FAIL_ON_EMPTY_COMMIT); @@ -81,9 +84,10 @@ public EmptyCommitTest(MavenRuntime.MavenRuntimeBuilder mavenBuilder) throws Exc } @MavenPluginTest - public void - GIVEN_fail_on_empty_commit_WHEN_the_staged_change_survives_the_formatting_THEN_the_commit_succeeds() - throws Exception { + @DisplayName( + "GIVEN fail on empty commit WHEN the staged change survives the formatting THEN the commit" + + " succeeds") + public void test3() throws Exception { commitBaseline(); installHooks(FAIL_ON_EMPTY_COMMIT); @@ -109,9 +113,10 @@ public EmptyCommitTest(MavenRuntime.MavenRuntimeBuilder mavenBuilder) throws Exc } @MavenPluginTest - public void - GIVEN_fail_on_empty_commit_WHEN_only_a_deletion_survives_the_formatting_THEN_the_commit_succeeds() - throws Exception { + @DisplayName( + "GIVEN fail on empty commit WHEN only a deletion survives the formatting THEN the commit" + + " succeeds") + public void test4() throws Exception { write(OTHER_JAVA, OTHER_BASELINE); jGit().add().addFilepattern(OTHER_JAVA).call(); commitBaseline(); @@ -131,9 +136,10 @@ public EmptyCommitTest(MavenRuntime.MavenRuntimeBuilder mavenBuilder) throws Exc } @MavenPluginTest - public void - GIVEN_fail_on_empty_commit_WHEN_the_formatting_reverts_the_merge_resolution_THEN_the_merge_commit_is_created() - throws Exception { + @DisplayName( + "GIVEN fail on empty commit WHEN the formatting reverts the merge resolution THEN the merge" + + " commit is created") + public void test5() throws Exception { commitBaseline(); String mainBranch = jGit().getRepository().getBranch(); diff --git a/core/src/test/java/com/cosium/code/format/MavenWrapperTest.java b/core/src/test/java/com/cosium/code/format/MavenWrapperTest.java index 51bbe651..e354dafb 100644 --- a/core/src/test/java/com/cosium/code/format/MavenWrapperTest.java +++ b/core/src/test/java/com/cosium/code/format/MavenWrapperTest.java @@ -11,6 +11,7 @@ import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; +import org.junit.jupiter.api.DisplayName; /** * Covers issue 90. @@ -34,8 +35,8 @@ public MavenWrapperTest(MavenRuntime.MavenRuntimeBuilder mavenBuilder) throws Ex } @MavenPluginTest - public void GIVEN_a_maven_wrapper_WHEN_installing_the_hooks_THEN_the_hook_runs_the_wrapper() - throws Exception { + @DisplayName("GIVEN a maven wrapper WHEN installing the hooks THEN the hook runs the wrapper") + public void test1() throws Exception { Path wrapper = installMavenWrapper(projectRoot()); installHooks(); @@ -44,9 +45,10 @@ public void GIVEN_a_maven_wrapper_WHEN_installing_the_hooks_THEN_the_hook_runs_t } @MavenPluginTest - public void - GIVEN_a_maven_wrapper_in_a_parent_directory_WHEN_installing_the_hooks_THEN_the_hook_runs_the_wrapper() - throws Exception { + @DisplayName( + "GIVEN a maven wrapper in a parent directory WHEN installing the hooks THEN the hook runs the" + + " wrapper") + public void test2() throws Exception { // The build is run from the module, while the wrapper sits at the root of the repository. Path wrapper = installMavenWrapper(projectRoot()); Path module = Files.createDirectories(projectRoot().resolve("module")); @@ -58,18 +60,19 @@ public void GIVEN_a_maven_wrapper_WHEN_installing_the_hooks_THEN_the_hook_runs_t } @MavenPluginTest - public void - GIVEN_no_maven_wrapper_WHEN_installing_the_hooks_THEN_the_hook_runs_the_maven_installation() - throws Exception { + @DisplayName( + "GIVEN no maven wrapper WHEN installing the hooks THEN the hook runs the maven installation") + public void test3() throws Exception { installHooks(); assertThat(readHookScript()).doesNotContain(MAVEN_WRAPPER); } @MavenPluginTest - public void - GIVEN_the_maven_wrapper_is_not_preferred_WHEN_installing_the_hooks_THEN_the_hook_runs_the_maven_installation() - throws Exception { + @DisplayName( + "GIVEN the maven wrapper is not preferred WHEN installing the hooks THEN the hook runs the" + + " maven installation") + public void test4() throws Exception { installMavenWrapper(projectRoot()); buildMavenExecution(projectRoot()) @@ -85,8 +88,8 @@ public void GIVEN_a_maven_wrapper_WHEN_installing_the_hooks_THEN_the_hook_runs_t * the selected wrapper is something git can actually run. */ @MavenPluginTest - public void GIVEN_a_maven_wrapper_WHEN_committing_THEN_the_wrapper_formats_the_staged_file() - throws Exception { + @DisplayName("GIVEN a maven wrapper WHEN committing THEN the wrapper formats the staged file") + public void test5() throws Exception { installMavenWrapper(projectRoot()); installHooks(); @@ -106,9 +109,9 @@ public void GIVEN_a_maven_wrapper_WHEN_committing_THEN_the_wrapper_formats_the_s } @MavenPluginTest - public void - GIVEN_a_maven_wrapper_WHEN_the_validation_fails_THEN_the_wrapper_is_the_command_to_run() - throws Exception { + @DisplayName( + "GIVEN a maven wrapper WHEN the validation fails THEN the wrapper is the command to run") + public void test6() throws Exception { installMavenWrapper(projectRoot()); buildMavenExecution(projectRoot()) diff --git a/core/src/test/java/com/cosium/code/format/PartiallyStagedFileTest.java b/core/src/test/java/com/cosium/code/format/PartiallyStagedFileTest.java index 296be004..a83dd389 100644 --- a/core/src/test/java/com/cosium/code/format/PartiallyStagedFileTest.java +++ b/core/src/test/java/com/cosium/code/format/PartiallyStagedFileTest.java @@ -12,6 +12,7 @@ import org.eclipse.jgit.lib.Repository; import org.eclipse.jgit.revwalk.RevWalk; import org.eclipse.jgit.treewalk.TreeWalk; +import org.junit.jupiter.api.DisplayName; /** * Covers issue 49, @@ -33,9 +34,10 @@ public PartiallyStagedFileTest(MavenRuntime.MavenRuntimeBuilder mavenBuilder) th } @MavenPluginTest - public void - GIVEN_partially_staged_file_WHEN_committing_THEN_staged_lines_are_formatted_and_unstaged_changes_survive() - throws Exception { + @DisplayName( + "GIVEN partially staged file WHEN committing THEN staged lines are formatted and unstaged" + + " changes survive") + public void test1() throws Exception { String baseline = "public class BadFormat {\n" + "\n" @@ -77,9 +79,10 @@ public PartiallyStagedFileTest(MavenRuntime.MavenRuntimeBuilder mavenBuilder) th } @MavenPluginTest - public void - GIVEN_formatting_conflicting_with_unstaged_changes_WHEN_committing_THEN_the_commit_still_succeeds() - throws Exception { + @DisplayName( + "GIVEN formatting conflicting with unstaged changes WHEN committing THEN the commit still" + + " succeeds") + public void test2() throws Exception { String baseline = "public class BadFormat {\n" + "\n" + " void a() {}\n" + "}\n"; commitBaseline(baseline); diff --git a/core/src/test/java/com/cosium/code/format/maven/MavenExecutablesTest.java b/core/src/test/java/com/cosium/code/format/maven/MavenExecutablesTest.java index 40717dd6..4cd34584 100644 --- a/core/src/test/java/com/cosium/code/format/maven/MavenExecutablesTest.java +++ b/core/src/test/java/com/cosium/code/format/maven/MavenExecutablesTest.java @@ -12,6 +12,7 @@ import java.util.Map; import java.util.Set; import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.io.TempDir; @@ -37,7 +38,8 @@ public void beforeEach() { } @Test - public void testMavenHomeExecutable() { + @DisplayName("Maven home executable") + public void test1() { systemProperties.put("maven.home", "/opt/maven"); Path expectedPath = Paths.get("/opt/maven/bin/mvn"); commandRunner.validExecutables.add(expectedPath.toString()); @@ -46,7 +48,8 @@ public void testMavenHomeExecutable() { } @Test - public void testMavenHomeDebugExecutable() { + @DisplayName("Maven home debug executable") + public void test2() { systemProperties.put("maven.home", "/opt/maven"); Path expectedPath = Paths.get("/opt/maven/bin/mvnDebug"); commandRunner.validExecutables.add(expectedPath.toString()); @@ -55,7 +58,8 @@ public void testMavenHomeDebugExecutable() { } @Test - public void testMavenPathExecutableFallback() { + @DisplayName("Maven path executable fallback") + public void test3() { systemProperties.put("maven.home", "/opt/maven"); commandRunner.validExecutables.add("mvn"); Path path = tested.select(false, false); @@ -63,7 +67,8 @@ public void testMavenPathExecutableFallback() { } @Test - public void testMavenPathDebugExecutableFallback() { + @DisplayName("Maven path debug executable fallback") + public void test4() { systemProperties.put("maven.home", "/opt/maven"); commandRunner.validExecutables.add("mvnDebug"); Path path = tested.select(true, false);