ru.yandex.qatools.allure.data.TestSuiteFiles Maven / Gradle / Ivy
package ru.yandex.qatools.allure.data;
import javax.xml.bind.JAXB;
import java.io.File;
import java.io.StringWriter;
import java.util.Collection;
import static ru.yandex.qatools.allure.config.AllureNamingUtils.listTestSuiteFiles;
import static ru.yandex.qatools.allure.data.utils.XslTransformationUtils.applyTransformations;
/**
* @author Dmitry Baev [email protected]
* Date: 02.12.13
*/
public class TestSuiteFiles {
public static final String SUITES_TO_TEST_RUN_1_XSL = "xsl/suites-to-testrun-1.xsl";
public static final String SUITES_TO_TEST_RUN_2_XSL = "xsl/suites-to-testrun-2.xsl";
public static final String SUITES_TO_TEST_RUN_3_XSL = "xsl/suites-to-testrun-3.xsl";
private String suiteFiles;
public TestSuiteFiles(File... dirs) {
Collection testSuitesFiles = listTestSuiteFiles(dirs);
ListFiles listFiles = createListFiles(testSuitesFiles);
suiteFiles = listFilesToString(listFiles);
}
private ListFiles createListFiles(Collection files) {
ListFiles listFiles = new ListFiles();
for (File file : files) {
listFiles.getFiles().add(file.toURI().toString());
}
return listFiles;
}
private String listFilesToString(ListFiles listFiles) {
StringWriter stringWriter = new StringWriter();
JAXB.marshal(new ObjectFactory().createListFiles(listFiles), stringWriter);
return stringWriter.toString();
}
public String generateTestRun() {
return applyTransformations(
suiteFiles,
SUITES_TO_TEST_RUN_1_XSL,
SUITES_TO_TEST_RUN_2_XSL,
SUITES_TO_TEST_RUN_3_XSL
);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy