Skip to content

Suite Sorting and Thread Count Support #97

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

Merged
merged 1 commit into from
Sep 23, 2022
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
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,18 @@ abstract class AbstractScalaTestMojo extends AbstractMojo {
*/
boolean parallel;

/**
* Set to true to enable suite sorting, this only takes effect if parallel is set to true.
* @parameter property="suiteSorting"
*/
boolean suiteSorting;

/**
* Set the thread count for parallel tests execution, this only takes effect if parallel is set to true.
* @parameter property="threadCount"
*/
int threadCount;

/**
* Comma separated list of packages containing suites to execute
* @parameter property="membersOnlySuites"
Expand Down Expand Up @@ -507,7 +519,13 @@ private List<String> tagsToExclude() {
}

private List<String> parallel() {
return parallel ? unmodifiableList(singletonList("-P")) : Collections.<String>emptyList();
if (parallel) {
String useSuiteSorting = suiteSorting ? "S" : "";
String useThreadCount = threadCount == 0 ? "" : ("" + threadCount);
return unmodifiableList(singletonList("-P" + useSuiteSorting + useThreadCount));
}
else
return Collections.<String>emptyList();
}

//
Expand Down
44 changes: 44 additions & 0 deletions src/test/scala/org/scalatest/tools/maven/PluginTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,50 @@ final class PluginTest
configure(_.parallel = false) should not contain ("-P")
}

def testConcurrentSuiteSorting {
configure { m =>
m.parallel = true
m.suiteSorting = true
} should containSlice("-PS")
}

def testConcurrentThreadCount {
configure { m =>
m.parallel = true
m.threadCount = 4
} should containSlice("-P4")
}

def testConcurrentSuiteSortingThreadCount {
configure { m =>
m.parallel = true
m.suiteSorting = true
m.threadCount = 4
} should containSlice("-PS4")
}

def testSuiteSorting {
// Suite sorting count should have no effect if parallel is not set to true.
configure { m =>
m.suiteSorting = true
} shouldNot containSlice ("-PS")
}

def testSuiteSortingThreadCount {
// Suite sorting and thread count should have no effect if parallel is not set to true.
configure { m =>
m.suiteSorting = true
m.threadCount = 4
} shouldNot containSlice ("-PS4")
}

def testThreadCount {
// Thread count should have no effect if parallel is not set to true.
configure { m =>
m.threadCount = 4
} shouldNot containSlice ("-P4")
}

def testSuites {
val suites: String = comma(" a ",
"b",
Expand Down