Added option to set the tests classpath
This commit is contained in:
parent
89a662a1c4
commit
65b9ea190b
8 changed files with 55 additions and 25 deletions
|
@ -52,6 +52,10 @@ public class TestNgOperation extends AbstractProcessOperation<TestNgOperation> {
|
|||
* The suites to run.
|
||||
*/
|
||||
protected final List<String> suites = new ArrayList<>();
|
||||
/**
|
||||
* The classpath entries used for running tests.
|
||||
*/
|
||||
protected final List<String> testClasspath = new ArrayList<>();
|
||||
private final List<String> args = new ArrayList<>();
|
||||
private BaseProject project;
|
||||
|
||||
|
@ -118,9 +122,15 @@ public class TestNgOperation extends AbstractProcessOperation<TestNgOperation> {
|
|||
|
||||
args.clear();
|
||||
args.add(javaTool());
|
||||
|
||||
args.add("-cp");
|
||||
args.add(String.format("%s:%s:%s", Path.of(project.libTestDirectory().getPath(), "*"),
|
||||
project.buildMainDirectory(), project.buildTestDirectory()));
|
||||
if (testClasspath.isEmpty()) {
|
||||
args.add(String.format("%s:%s:%s", Path.of(project.libTestDirectory().getPath(), "*"),
|
||||
project.buildMainDirectory(), project.buildTestDirectory()));
|
||||
} else {
|
||||
args.add(String.join(":", testClasspath));
|
||||
}
|
||||
|
||||
args.add("org.testng.TestNG");
|
||||
|
||||
options.forEach((k, v) -> {
|
||||
|
@ -406,6 +416,14 @@ public class TestNgOperation extends AbstractProcessOperation<TestNgOperation> {
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specifies the classpath entries used to run tests.
|
||||
*/
|
||||
public TestNgOperation testClasspath(String... entry) {
|
||||
testClasspath.addAll(Arrays.stream(entry).toList());
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specifies a jar file that contains test classes. If a {@code testng.xml} file is found at the root of that
|
||||
* jar file, it will be used, otherwise, all the test classes found in this jar file will be considered test
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue