From 36858a90ab246defad2899339e9ac9f0b1018914 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 1 Apr 2016 10:59:55 +0200 Subject: [PATCH] Add fixes to avoid crash whether a TC is failed in the test initialize and file not found crash --- TrxerConsole/Program.cs | 13 +++++++++++-- TrxerConsole/Trxer.xslt | 8 ++++++-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/TrxerConsole/Program.cs b/TrxerConsole/Program.cs index 6ae196d..6f265ae 100644 --- a/TrxerConsole/Program.cs +++ b/TrxerConsole/Program.cs @@ -22,7 +22,7 @@ class Program /// Main entry of TrxerConsole /// /// First cell shoud be TRX path - static void Main(string[] args) + internal static void Main(string[] args) { if (args.Any() == false) { @@ -54,7 +54,16 @@ private static void Transform(string fileName, XmlDocument xsl, string outputFil XslCompiledTransform x = new XslCompiledTransform(true); x.Load(xsl, new XsltSettings(true, true), null); Console.WriteLine("Transforming..."); - x.Transform(fileName, outputFile); + + try + { + x.Transform(fileName, outputFile); + } + catch (FileNotFoundException) + { + Console.WriteLine("ERROR. File not found: " + fileName); + } + Console.WriteLine("Done transforming xml into html"); } diff --git a/TrxerConsole/Trxer.xslt b/TrxerConsole/Trxer.xslt index bd71fb1..50db2e8 100644 --- a/TrxerConsole/Trxer.xslt +++ b/TrxerConsole/Trxer.xslt @@ -41,8 +41,12 @@ public string ToExactTimeDefinition(string duration) { - return ToExtactTime(TimeSpan.Parse(duration).TotalMilliseconds); - } + // Fix in order to prevent crash when execution is aborted + if(duration != null && duration.Length > 0) + return ToExtactTime(TimeSpan.Parse(duration).TotalMilliseconds); + else + return "0"; + } public string ToExactTimeDefinition(string start,string finish) {