Skip to content

Commit

Permalink
Add testType parameter (all, unit or integration) parameter to test p…
Browse files Browse the repository at this point in the history
…hase
  • Loading branch information
Jean-Philippe Briend committed Jul 15, 2011
1 parent bd18b73 commit f0d4e8c
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion src/main/java/org/grails/maven/plugin/MvnTestMojo.java
Expand Up @@ -58,6 +58,15 @@ public class MvnTestMojo extends AbstractGrailsMojo {
*/
private boolean testFailureIgnore;

/**
* Choose which type of tests to launch (passes --unit or --integration to Grails command).
* Default is all : Unit tests + Integration tests.
* Other values are 'unit' and 'integration'.
*
* @parameter default-value="all" expression="${grails.test.type}"
*/
private String testType;

public void execute() throws MojoExecutionException, MojoFailureException {
if (skip) {
return;
Expand All @@ -81,8 +90,23 @@ public void execute() throws MojoExecutionException, MojoFailureException {
}
}

if (testType == null || "".equals(testType)) {
testType = "all";
}

try {
runGrails("TestApp", "--unit --integration", true);
// Unit tests only
if ("unit".equalsIgnoreCase(testType)) {
runGrails("TestApp", "--unit", true);
}
// Integration tests only
else if ("integration".equalsIgnoreCase(testType)) {
runGrails("TestApp", "--integration", true);
}
// All tests
else {
runGrails("TestApp", "--unit --integration", true);
}
} catch (MojoExecutionException me) {
if (!testFailureIgnore) {
throw me;
Expand Down

0 comments on commit f0d4e8c

Please sign in to comment.