public static void ExportResultsToJUnitXML(ISearchCmdletBaseDataObject cmdlet, string path)
{
try {
// 20150925
// var gathered = new GatherTestResultsCollections();
var gathered = ProxyFactory.Get<GatherTestResultsCollections>();
gathered.GatherCollections(cmdlet);
// 20150925
// var testResultsExporter = new TestResultsExporter();
var testResultsExporter = ProxyFactory.Get<TestResultsExporter>();
var suitesElement = testResultsExporter.CreateSuitesXElementWithParameters(
gathered.TestSuites,
gathered.TestScenarios,
gathered.TestResults,
(new XMLElementsJUnitStruct()));
var document = new XDocument();
document.Add(suitesElement);
document.Save(path);
}
catch (Exception eCreateDocument) {
// 20140720
// cmdlet.WriteError(
// cmdlet,
// "Unable to save XML report to the file '" +
// path +
// "'. " +
// eCreateDocument.Message,
// "FailedToSaveReport",
// ErrorCategory.InvalidOperation,
// true);
throw new Exception(
"Unable to save XML report to the file '" +
path +
"'. " +
eCreateDocument.Message);
}
}