Skip to content

Commit

Permalink
Merge pull request #4 from guillaumeLamanda/main
Browse files Browse the repository at this point in the history
fix mvn arguments declaration
  • Loading branch information
andy-bell101 authored Jun 9, 2023
2 parents 1255a07 + 6658888 commit 5da02d3
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 10 deletions.
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

0 comments on commit 5da02d3

Please sign in to comment.