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

-S for Seed Argument Support #102

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
22 changes: 22 additions & 0 deletions src/main/java/org/scalatest/tools/maven/AbstractScalaTestMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,12 @@ abstract class AbstractScalaTestMojo extends AbstractMojo {
*/
String jUnitClasses;

/**
* Set the seed used by generators of property-driven tests.
* @parameter property="seed"
*/
String seed;

/**
* Option to specify the forking mode. Can be "never" or "once". "always", which would
* fork for each test-class, may be supported later.
Expand Down Expand Up @@ -467,6 +473,7 @@ List<String> sharedConfiguration() {
addAll(testsFiles());
addAll(junitClasses());
addAll(spanScaleFactor());
addAll(seed());
}});
}

Expand Down Expand Up @@ -667,4 +674,19 @@ private List<String> testsFiles() {
private List<String> junitClasses() {
return suiteArg("-j", jUnitClasses);
}

private List<String> seed() {
List<String> list = new ArrayList<String>();
if (seed != null) {
try {
Long.parseLong(seed);
list.add("-S");
list.add(seed);
}
catch (NumberFormatException e) {
throw new RuntimeException("Invalid seed value: " + seed);
}
}
return unmodifiableList(list);
}
}
7 changes: 7 additions & 0 deletions src/test/scala/org/scalatest/tools/maven/PluginTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,12 @@ final class PluginTest
configure(_.memoryFiles = comma("a", "b", "c")) should containSuiteArgs("-M", "a", "b", "c")
}

def testSeed {
configure { m =>
m.seed = "1234567890"
} should containSlice("-S", "1234567890")
}

def testTestsFiles {
configure(_.testsFiles = comma("nonesuch", "pom.xml", "src")) should containSuiteArgs("-A", "pom.xml", "src")
}
Expand Down Expand Up @@ -266,4 +272,5 @@ final class PluginTest
MojoUtils.stripNewLines("-XmsXg\r\n-XmxYg -XX:MaxPermSize=Zm") should be("-XmsXg -XmxYg -XX:MaxPermSize=Zm")
MojoUtils.stripNewLines("-XmsXg\r\n-XmxYg") should be("-XmsXg -XmxYg")
}

}