Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix mvn arguments declaration #4

Merged
merged 3 commits into from
Jun 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lua/neotest-java/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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, " "),
Expand Down
25 changes: 25 additions & 0 deletions tests/data/maven_project/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>example</artifactId>
<version>0.0.1-SNAPSHOT</version>

<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.24.2</version>
<scope>test</scope>
</dependency>
</dependencies>

</project>
8 changes: 4 additions & 4 deletions tests/data/maven_project/src/main/java/FileWithTests.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
public class Junk {
public boolean some_result() {
return true;
}
public class FileWithTests {
public boolean some_result() {
return true;
}
}
8 changes: 4 additions & 4 deletions tests/init_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down Expand Up @@ -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({
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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)

Expand Down