Search in sources :

Example 21 with XmlSuite

use of org.testng.xml.XmlSuite in project buck by facebook.

the class TestNGRunner method createXmlSuite.

private XmlSuite createXmlSuite(Class<?> c) {
    XmlSuite xmlSuite = new XmlSuite();
    xmlSuite.setName("TmpSuite");
    xmlSuite.setTimeOut(String.valueOf(defaultTestTimeoutMillis));
    XmlTest xmlTest = new XmlTest(xmlSuite);
    xmlTest.setName("TmpTest");
    xmlTest.setXmlClasses(Collections.singletonList(new XmlClass(c)));
    return xmlSuite;
}
Also used : XmlSuite(org.testng.xml.XmlSuite) XmlTest(org.testng.xml.XmlTest) XmlClass(org.testng.xml.XmlClass)

Example 22 with XmlSuite

use of org.testng.xml.XmlSuite in project intellij-community by JetBrains.

the class SearchingForTestsTask method composeTestSuiteFromXml.

private void composeTestSuiteFromXml() throws CantRunException {
    final Map<String, String> buildTestParams = buildTestParameters();
    try {
        if (buildTestParams.isEmpty()) {
            String path = new File(myData.getSuiteName()).getAbsolutePath() + "\n";
            FileUtil.writeToFile(myTempFile, path.getBytes(CharsetToolkit.UTF8_CHARSET), true);
            return;
        }
        final Parser parser = new Parser(myData.getSuiteName());
        parser.setLoadClasses(false);
        final Collection<XmlSuite> suites = parser.parse();
        for (XmlSuite suite : suites) {
            Map<String, String> params = suite.getParameters();
            params.putAll(buildTestParams);
            final String fileId = FileUtil.sanitizeFileName(myProject.getName() + '_' + suite.getName() + '_' + Integer.toHexString(suite.getName().hashCode()) + ".xml");
            final File suiteFile = new File(PathManager.getSystemPath(), fileId);
            FileWriter fileWriter = new FileWriter(suiteFile);
            try {
                fileWriter.write(suite.toXml());
            } finally {
                fileWriter.close();
            }
            String path = suiteFile.getAbsolutePath() + "\n";
            FileUtil.writeToFile(myTempFile, path.getBytes(CharsetToolkit.UTF8_CHARSET), true);
        }
    } catch (Exception e) {
        throw new CantRunException("Unable to parse suite: " + e.getMessage());
    }
}
Also used : CantRunException(com.intellij.execution.CantRunException) XmlSuite(org.testng.xml.XmlSuite) ExecutionException(com.intellij.execution.ExecutionException) CantRunException(com.intellij.execution.CantRunException) Parser(org.testng.xml.Parser)

Aggregations

XmlSuite (org.testng.xml.XmlSuite)22 XmlTest (org.testng.xml.XmlTest)12 XmlClass (org.testng.xml.XmlClass)8 XmlInclude (org.testng.xml.XmlInclude)5 ArrayList (java.util.ArrayList)3 File (java.io.File)2 Test (org.junit.Test)2 SuiteRunnerMap (org.testng.internal.SuiteRunnerMap)2 Parser (org.testng.xml.Parser)2 XmlMethodSelector (org.testng.xml.XmlMethodSelector)2 ParameterException (com.beust.jcommander.ParameterException)1 CantRunException (com.intellij.execution.CantRunException)1 ExecutionException (com.intellij.execution.ExecutionException)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 List (java.util.List)1 Map (java.util.Map)1 JarEntry (java.util.jar.JarEntry)1 JarFile (java.util.jar.JarFile)1