diff --git a/lua/neotest-java/init.lua b/lua/neotest-java/init.lua index cfbea49..d2194de 100644 --- a/lua/neotest-java/init.lua +++ b/lua/neotest-java/init.lua @@ -223,8 +223,8 @@ function M.build_spec(args) "mvn", } local maven_args = get_maven_args_for_position(position, tree) - local joined_args = "Dtest=" .. table.concat(maven_args, ",") - vim.list_extend(command, { joined_args, "test" }) + local joined_args = "-Dtest=" .. table.concat(maven_args, ",") + vim.list_extend(command, { "test", joined_args }) end local output = { command = table.concat(command, " "), diff --git a/tests/data/maven_project/pom.xml b/tests/data/maven_project/pom.xml index e69de29..c7afad1 100644 --- a/tests/data/maven_project/pom.xml +++ b/tests/data/maven_project/pom.xml @@ -0,0 +1,25 @@ + + + + 4.0.0 + com.example + example + 0.0.1-SNAPSHOT + + + + junit + junit + 4.13.2 + test + + + org.assertj + assertj-core + 3.24.2 + test + + + + diff --git a/tests/data/maven_project/src/main/java/FileWithTests.java b/tests/data/maven_project/src/main/java/FileWithTests.java index 9998105..fd47901 100644 --- a/tests/data/maven_project/src/main/java/FileWithTests.java +++ b/tests/data/maven_project/src/main/java/FileWithTests.java @@ -1,5 +1,5 @@ -public class Junk { - public boolean some_result() { - return true; - } +public class FileWithTests { + public boolean some_result() { + return true; + } } diff --git a/tests/init_spec.lua b/tests/init_spec.lua index c29deab..6dd0117 100644 --- a/tests/init_spec.lua +++ b/tests/init_spec.lua @@ -363,7 +363,7 @@ describe("build_spec", function() return data.id end) local spec = plugin.build_spec({ tree = tree }) - assert.equals(spec.command, "mvn Dtest=subdir.FileWithTests#passing_test test") + assert.equals(spec.command, "mvn test -Dtest=subdir.FileWithTests#passing_test") end) async.it("maven - successful on single namespace", function() local tree = Tree.from_list({ @@ -396,7 +396,7 @@ describe("build_spec", function() return data.id end) local spec = plugin.build_spec({ tree = tree }) - assert.equals(spec.command, "mvn Dtest=subdir.FileWithTests test") + assert.equals(spec.command, "mvn test -Dtest=subdir.FileWithTests") end) async.it("maven - runs on entire file in subdir", function() local tree = Tree.from_list({ @@ -438,7 +438,7 @@ describe("build_spec", function() return x.id end) local spec = plugin.build_spec({ tree = tree }) - assert.equals(spec.command, "mvn Dtest=subdir.FileWithTests test") + assert.equals(spec.command, "mvn test -Dtest=subdir.FileWithTests") end) async.it("maven - runs on entire directory", function() local dir = path_join(maven_files.root, "src", "test", "java", "subdir") @@ -523,7 +523,7 @@ describe("build_spec", function() return x.id end) local spec = plugin.build_spec({ tree = tree }) - assert.equals(spec.command, "mvn Dtest=subdir.FileWithTests,subdir.AnotherFileWithTests test") + assert.equals(spec.command, "mvn test -Dtest=subdir.FileWithTests,subdir.AnotherFileWithTests") end) end)