io.github.ericdriggs.reportcard.xml.surefire.SurefireParserUtil Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of reportcard-model Show documentation
Show all versions of reportcard-model Show documentation
test report metrics and trend analysis reporting :: reportcard-model
package io.github.ericdriggs.reportcard.xml.surefire;
import io.github.ericdriggs.file.FileUtils;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.List;
public class SurefireParserUtil {
private SurefireParserUtil() {
//call statically
}
public static List parseTestSuitesFromPathAndRegex(String absolutePath, String fileNameRegex) {
List xmlStringList = FileUtils.fileContentsFromPathAndRegex(absolutePath, fileNameRegex);
return parseTestSuites(xmlStringList);
}
public static List parseTestSuites(List xmlStringList) {
List testsuites = new ArrayList<>();
for ( String xmlString : xmlStringList) {
testsuites.add(parseTestSuite(xmlString));
}
return testsuites;
}
public static Testsuite parseTestSuite(String xmlString) {
JAXBContext jaxbContext;
try {
jaxbContext = JAXBContext.newInstance(Testsuite.class);
Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
Testsuite testsuite = (Testsuite) jaxbUnmarshaller.unmarshal(new StringReader(xmlString));
return testsuite;
} catch (JAXBException e) {
throw new RuntimeException(e);
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy