public class TestNG {
public static void test(MxTest mxtest, String jvmarg) {
// use default TestNG reports
TestNGAntTask testng = new TestNGAntTask();
testng.setTaskName("test");
testng.setProject(mxtest.getProject());
testng.init();
if (!StringUtils.isEmpty(jvmarg)) {
testng.createJvmarg().setValue(jvmarg);
}
testng.setWorkingDir(mxtest.getProject().getBaseDir());
testng.setOutputDir(mxtest.getTestReports());
testng.setFailureProperty(mxtest.getFailureProperty());
testng.createClasspath().add(mxtest.getUnitTestClasspath());
testng.addClassfileset(mxtest.getUnitTests());
// Cobertura properties
testng.addSysproperty(mxtest.getCoberturaFileProperty());
// EMMA properties
testng.addSysproperty(mxtest.getEmmaFileProperty());
testng.addSysproperty(mxtest.getEmmaMergeProperty());
// configure properties from Moxie file
MaxmlMap attributes = mxtest.getBuild().getConfig().getTaskAttributes("testng");
if (attributes != null) {
AttributeReflector.setAttributes(mxtest.getProject(), testng, attributes);
}
testng.execute();
}