From 86758273868fb83159711c960c5daac8ce3bec72 Mon Sep 17 00:00:00 2001 From: Guillaume Lamanda Date: Fri, 9 Jun 2023 17:14:01 +0200 Subject: [PATCH 1/3] fix mvn arguments declaration --- lua/neotest-java/init.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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, " "), From 39d6967ddc8bbb8fe69512f0a60db0f89d0d43c5 Mon Sep 17 00:00:00 2001 From: Guillaume Lamanda Date: Fri, 9 Jun 2023 17:44:27 +0200 Subject: [PATCH 2/3] fix maven project example --- tests/data/maven_project/pom.xml | 25 +++++++++++++++++++ .../src/main/java/FileWithTests.java | 8 +++--- 2 files changed, 29 insertions(+), 4 deletions(-) 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; + } } From 66588885fb9447b32614224a19b83e497cc08dcb Mon Sep 17 00:00:00 2001 From: Guillaume Lamanda Date: Fri, 9 Jun 2023 17:47:39 +0200 Subject: [PATCH 3/3] fix test --- tests/init_spec.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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)