public void RunTwoParams() { doc.LoadXml("<seeflaw><param name='param1' value='Arne'/><param name='param2' argument='user'/></seeflaw>"); argDic.Add("user", "Kalle"); seeFlaw = new SeeFlaw(); seeFlaw.AddDetails(doc, null, resultDoc, argDic, null, null); seeFlaw.SetTestTime(); seeFlaw.RunTestCase(); string expected = "<h1><center>SeeFlaw v1.0 run</center></h1><br />"; expected += "<h2>testfile</h2><br />"; expected += "<table border=\"0\" cellpadding=\"0\" class=\"step_passed\"><tr><td><table width=\"100%\">"; expected += "<tr><th align=\"left\" bgcolor=\"lightgreen\" class=\"title\">param</th></tr></table></td></tr>"; expected += "<tr><td><table border=\"1\" cellpadding=\"3\" cellspacing=\"0\" width=\"100%\">"; expected += "<tr><td class=\"status_passed\">Type</td><td bgcolor=\"#AAAAFF\" class=\"input_title\">name</td><td bgcolor=\"#AAAAFF\" class=\"input_title\">value</td><td bgcolor=\"#AAAAFF\" class=\"input_title\">argument</td><td bgcolor=\"#EEAAFF\" class=\"output_title\" colspan=\"2\">read_value</td></tr>"; expected += "<tr><td bgcolor=\"lightgreen\" class=\"statusvalue_passed\">Param</td><td bgcolor=\"#CCCCFF\" class=\"input_value\">param1</td><td bgcolor=\"#CCCCFF\" class=\"input_value\">Arne</td><td bgcolor=\"#CCCCFF\" class=\"input_value\" /><td bgcolor=\"lightgreen\" class=\"outputvalue_passed\" colspan=\"2\" /></tr>"; expected += "<tr><td bgcolor=\"lightgreen\" class=\"statusvalue_passed\">Param</td><td bgcolor=\"#CCCCFF\" class=\"input_value\">param2</td><td bgcolor=\"#CCCCFF\" class=\"input_value\" /><td bgcolor=\"#CCCCFF\" class=\"input_value\">user</td><td bgcolor=\"lightgreen\" class=\"outputvalue_passed\" colspan=\"2\">Kalle</td></tr>"; expected += "</table></td></tr></table><br />"; System.Console.WriteLine(resultDoc.FirstChild.InnerXml); NUnit.Framework.Assert.AreEqual(expected, resultDoc.FirstChild.LastChild.InnerXml); }
public void RunTest2() { doc.LoadXml(xml2); argDic["testfile"] = "xml2"; argDic.Add("user", "Arne"); seeFlaw = new SeeFlaw(); seeFlaw.AddDetails(doc, null, resultDoc, argDic, null, null); seeFlaw.RunTestCase(); System.Console.WriteLine(resultDoc.FirstChild.OuterXml); }
public void RunTextTest() { string testXml = "<seeflaw><text>Comment1 line1</text><text>Comment1 line2</text><call fixture='SeeFlawRunner.ExampleFixture' method='SingleOutputExampleMethod'><input name='Arne'/><output message='Hello Arne'/></call><text>Comment2</text></seeflaw>"; doc.LoadXml(testXml); seeFlaw = new SeeFlaw(); seeFlaw.AddDetails(doc, null, resultDoc, argDic, null, null); seeFlaw.SetTestTime(); XmlDocument loadDoc = new XmlDocument(); XmlElement resultElement = resultDoc.CreateElement("seeflawresult"); bool successful = seeFlaw.RunTest(doc.GetElementsByTagName("seeflaw")[0], resultElement); System.Console.WriteLine(resultElement.OuterXml); seeFlaw.TransformToHtml(resultElement); XmlNode resultNode = resultDoc.FirstChild.LastChild; string expected = "<table border=\"1\" cellpadding=\"0\" class=\"step_text\"><tr><td><table width=\"100%\" bgcolor=\"yellow\">"; expected += "<tr><th align=\"left\" class=\"text\">Comment1 line1</th></tr>"; expected += "<tr><th align=\"left\" class=\"text\">Comment1 line2</th></tr>"; expected += "</table></td></tr></table><br />"; expected += "<table border=\"0\" cellpadding=\"0\" class=\"step_passed\"><tr><td><table width=\"100%\">"; expected += "<tr><th align=\"left\" bgcolor=\"lightgreen\" class=\"title\">SeeFlawRunner.ExampleFixture : SingleOutputExampleMethod</th></tr></table></td></tr>"; expected += "<tr><td><table border=\"1\" cellpadding=\"3\" cellspacing=\"0\" width=\"100%\">"; expected += "<tr><td class=\"status_passed\">Type</td><td class=\"time_value\">Time</td><td bgcolor=\"#AAAAFF\" class=\"input_title\">name</td><td bgcolor=\"#EEAAFF\" class=\"output_title\" colspan=\"2\">message</td></tr>"; expected += "<tr><td bgcolor=\"lightgreen\" class=\"statusvalue_passed\">Match</td><td class=\"time_value\">(00:00:00)</td><td bgcolor=\"#CCCCFF\" class=\"input_value\">Arne</td><td bgcolor=\"lightgreen\" class=\"outputvalue_passed\" colspan=\"2\">Hello Arne</td></tr>"; expected += "</table></td></tr></table><br />"; expected += "<table border=\"1\" cellpadding=\"0\" class=\"step_text\"><tr><td><table width=\"100%\" bgcolor=\"yellow\">"; expected += "<tr><th align=\"left\" class=\"text\">Comment2</th></tr>"; expected += "</table></td></tr></table><br />"; System.Console.WriteLine(resultNode.InnerXml); NUnit.Framework.Assert.AreEqual(expected, resultNode.InnerXml); }
public void RunTest() { doc.LoadXml(xml); argDic["testfile"] = "xml"; seeFlaw = new SeeFlaw(); seeFlaw.AddDetails(doc, resultDoc, htmlDoc, argDic, null, null); seeFlaw.SetTestTime(); seeFlaw.RunTestCase(); System.Console.WriteLine(resultDoc.FirstChild.OuterXml); System.Console.WriteLine(htmlDoc.FirstChild.OuterXml); }
public void RunSingleTestWithParamValue() { doc.LoadXml("<seeflaw><param name='param1' value='Arne'/><call fixture='SeeFlawRunner.ExampleFixture' method='SingleOutputExampleMethod'><input name='param1'/><output message='Hello Arne'/></call></seeflaw>"); seeFlaw = new SeeFlaw(); seeFlaw.AddDetails(doc, null, resultDoc, argDic, null, null); seeFlaw.SetTestTime(); seeFlaw.RunTestCase(); XmlNode resultNode = resultDoc.FirstChild.LastChild; string expected = "<h1><center>SeeFlaw v1.0 run</center></h1><br />"; expected += "<h2>testfile</h2><br />"; expected += "<table border=\"0\" cellpadding=\"0\" class=\"step_passed\"><tr><td><table width=\"100%\">"; expected += "<tr><th align=\"left\" bgcolor=\"lightgreen\" class=\"title\">param</th></tr></table></td></tr>"; expected += "<tr><td><table border=\"1\" cellpadding=\"3\" cellspacing=\"0\" width=\"100%\">"; expected += "<tr><td class=\"status_passed\">Type</td><td bgcolor=\"#AAAAFF\" class=\"input_title\">name</td><td bgcolor=\"#AAAAFF\" class=\"input_title\">value</td></tr>"; expected += "<tr><td bgcolor=\"lightgreen\" class=\"statusvalue_passed\">Param</td><td bgcolor=\"#CCCCFF\" class=\"input_value\">param1</td><td bgcolor=\"#CCCCFF\" class=\"input_value\">Arne</td></tr>"; expected += "</table></td></tr></table><br />"; expected += "<table border=\"0\" cellpadding=\"0\" class=\"step_passed\"><tr><td><table width=\"100%\">"; expected += "<tr><th align=\"left\" bgcolor=\"lightgreen\" class=\"title\">SeeFlawRunner.ExampleFixture : SingleOutputExampleMethod</th></tr></table></td></tr>"; expected += "<tr><td><table border=\"1\" cellpadding=\"3\" cellspacing=\"0\" width=\"100%\">"; expected += "<tr><td class=\"status_passed\">Type</td><td class=\"time_value\">Time</td><td bgcolor=\"#AAAAFF\" class=\"input_title\">name</td><td bgcolor=\"#EEAAFF\" class=\"output_title\" colspan=\"2\">message</td></tr>"; expected += "<tr><td bgcolor=\"lightgreen\" class=\"statusvalue_passed\">Match</td><td class=\"time_value\">(00:00:00)</td><td bgcolor=\"#CCCCFF\" class=\"input_value\">Arne</td><td bgcolor=\"lightgreen\" class=\"outputvalue_passed\" colspan=\"2\">Hello Arne</td></tr>"; expected += "</table></td></tr></table><br />"; System.Console.WriteLine(resultNode.InnerXml); NUnit.Framework.Assert.AreEqual(expected, resultNode.InnerXml); }
public void RunSingleTestFixtureException() { doc.LoadXml("<seeflaw><call fixture='SeeFlawRunner.ExampleFixture' method='SingleOutputExampleMethod'><input test='error'/><output message='some'/></call></seeflaw>"); seeFlaw = new SeeFlaw(); seeFlaw.AddDetails(doc, resultDoc, htmlDoc, argDic, null, null); seeFlaw.SetTestTime(); seeFlaw.RunTestCase(); System.Console.WriteLine(resultDoc.FirstChild.OuterXml); XmlNode bodyNode = htmlDoc.FirstChild.LastChild; string expected = "<h1><center>SeeFlaw v1.0 run</center></h1><br />"; expected += "<h2>testfile</h2><br />"; expected += "<table border=\"0\" cellpadding=\"0\" class=\"step_error\"><tr><td><table width=\"100%\">"; expected += "<tr><th align=\"left\" bgcolor=\"#FF5555\" class=\"title\">SeeFlawRunner.ExampleFixture : SingleOutputExampleMethod</th></tr></table></td></tr>"; expected += "<tr><td><table border=\"1\" cellpadding=\"3\" cellspacing=\"0\" width=\"100%\">"; expected += "<tr><td class=\"status_error\">Type</td><td class=\"time_value\">Time</td><td bgcolor=\"#AAAAFF\" class=\"input_title\">test</td><td bgcolor=\"#EEAAFF\" class=\"output_title\" colspan=\"2\">message</td></tr>"; expected += "<tr><td bgcolor=\"#FF0000\" class=\"statusvalue_error\"><a href=\"#Exception1\">Exception1</a></td><td class=\"time_value\">(00:00:00)</td><td bgcolor=\"#CCCCFF\" class=\"input_value\">error</td><td bgcolor=\"#BBBBBB\" class=\"outputvalue_unprocessed\" colspan=\"2\">some</td></tr>"; expected += "</table></td></tr></table>"; expected += "<br /><h2>Exceptions Listing</h2>"; expected += "<table border=\"0\" cellpadding=\"3\" cellspacing=\"0\" width=\"100%\">"; expected += "<tr><td valign=\"top\"><a name=\"Exception1\">Exception1</a></td>"; expected += "<td valign=\"top\"><pre valign=\"top\">Mandatory input 'name' missing."; System.Console.WriteLine(bodyNode.OuterXml); int length = System.Math.Min(expected.Length, bodyNode.InnerXml.Length - 1); string resultStr = bodyNode.InnerXml.Substring(0, length); NUnit.Framework.Assert.AreEqual(expected, resultStr); }
public bool RunTest(TestNode testNode, Dictionary<string, string> argDic, System.IO.StringWriter strWr) { XmlDocument testDoc = new XmlDocument(); XmlDocument resultDoc = new XmlDocument(); testDoc.Load(testNode.testFile); argDic["testfile"] = testNode.testFile; SeeFlawRunner.TestFinishedDelegate callBack = new SeeFlawRunner.TestFinishedDelegate(this.TestFinished); System.AppDomain SeeFlawRunnerDomain = System.AppDomain.CreateDomain("SeeFlawRunnerDomain"); System.Runtime.Remoting.ObjectHandle handle = SeeFlawRunnerDomain.CreateInstance("SeeFlawRunner", "SeeFlawRunner.SeeFlaw"); seeFlaw = (SeeFlawRunner.SeeFlaw) handle.Unwrap(); seeFlaw.AddDetails(testDoc, null, resultDoc, argDic, callBack, bgRunner); Thread testThread = new Thread(new ThreadStart(seeFlaw.RunTestCase)); testThread.Start(); while (!isFinished) { testThread.Join(200); if (AddLog(testNode, strWr)) { bgRunner.ReportProgress(ProgressEvent.LogUpdated, testNode); } } System.AppDomain.Unload(SeeFlawRunnerDomain); if (!testSuccessful && error != "") { XmlElement htmlElement = resultDoc.CreateElement("html"); XmlElement bodyElement = resultDoc.CreateElement("body"); string[] errorLines = error.Split(new char[] { '\n' }); for (int line = 0; line < errorLines.Length; line++) { bodyElement.AppendChild(resultDoc.CreateTextNode(errorLines[line])); bodyElement.AppendChild(resultDoc.CreateElement("br")); } htmlElement.AppendChild(bodyElement); resultDoc.AppendChild(htmlElement); } testNode.htmlOutput = resultDoc.OuterXml; AddLog(testNode, strWr); return testSuccessful; }
static void Main(string[] args) { try { if (args.Length <= 1) { ShowUsage(); } Dictionary<string, string> argsDic = ReadArguments(args); if (!argsDic.ContainsKey("testfile")) { throw new Exception("TestFile argument missing"); } string testFile = argsDic["testfile"]; if (!System.IO.File.Exists(testFile)) { throw new Exception("No such TestFile: " + testFile); } string outFile = ""; string outXmlFile = ""; argsDic.TryGetValue("outfile", out outFile); argsDic.TryGetValue("outxmlfile", out outXmlFile); XmlDocument testDoc = new XmlDocument(); testDoc.Load(testFile); XmlDocument outDoc = new XmlDocument(); XmlDocument outXmlDoc = null; if (!string.IsNullOrEmpty(outXmlFile)) { outXmlDoc = new XmlDocument(); } SeeFlaw runner = new SeeFlaw(); runner.AddDetails(testDoc, outXmlDoc, outDoc, argsDic, null, null); bool successful = runner.RunTestCaseSuccessful(); if (!string.IsNullOrEmpty(outFile)) { outDoc.Save(outFile); } if (!string.IsNullOrEmpty(outXmlFile)) { outXmlDoc.Save(outXmlFile); } if (!successful) { Environment.Exit(2); } } catch (Exception ex) { System.Console.WriteLine(ex.ToString()); Environment.Exit(1); } }