package org.eobjects.build;

import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;

import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.Parameter;

public abstract class AbstractDotnetTestMojo extends AbstractDotnetMojo {

    @Parameter(property = "dotnet.test.outputxml", required = false)
    private File outputXml;

    @Parameter(property = "dotnet.test.forcexunit", required = false)
    private Boolean forceXUnit;

    @Parameter(property = "dotnet.test.logger", required = false)
    private String logger;

    public void executeInternal() throws MojoFailureException {
        final PluginHelper helper = getPluginHelper();
        ArrayList<String> argsList = new ArrayList<String>(Arrays.asList("dotnet", forceXUnit ? "xunit" : "test", "-c", helper.getBuildConfiguration()));
        if(outputXml != null) {
            outputXml.getParentFile().mkdirs();
            argsList.add("-xml");
            argsList.add(outputXml.getPath());
        }
        if(logger != null) {
            argsList.add("-l");
            argsList.add(logger);
        }
        for (File subDirectory : helper.getProjectDirectories()) {
            if (isTestRunnable(subDirectory)) {
                helper.executeCommand(subDirectory, argsList.toArray(new String[argsList.size()]));
            }
        }
    }

    private boolean isTestRunnable(File subDirectory) {
        return getPluginHelper().getProjectFile(subDirectory).isTestProject();
    }
}

@@ -422,18 +422,20 @@
 est.
-forcexunit
+test-command
 %22, r
@@ -453,40 +453,63 @@
 alse
-)%0A    private Boolean forceXUnit
+, defaultValue = %22test%22)%0A    private String testCommand
 ;%0A%0A 
@@ -807,37 +807,19 @@
 t%22, 
-forceXUnit ? %22xunit%22 : %22test%22
+testCommand
 , %22-

Replace boolean "forcexunit" with string "test-command"