static void Main(string[] args) { //if test one case can open the log to console TraceMethod.SetDefaultTraceType(new TraceMethod.TraceType[] { TraceMethod.TraceType.CONCOLE, TraceMethod.TraceType.FILE }); //TraceMethod.SetDefaultTraceType(new TraceMethod.TraceType[] { TraceMethod.TraceType.FILE }); int cmd = 0; Console.WriteLine("input the test case number (0 then quit; 111 then run all cases):"); do { cmd = 4;//*111;/*/int.Parse(Console.ReadLine()); //cmd = Convert.ToInt16(Console.ReadLine()); if (cmd == 111) { TestCaseParser.RunAllTestCase(); } else if (cmd.Equals(0)) { break; } else if (TestCaseParser.IsTestCaseExist(cmd)) { TestCaseParser.RunTestCase(cmd); } else { Console.WriteLine($"input {cmd} is invalid!"); } TestCaseParser.Report(); Console.ReadLine(); Console.WriteLine("请输入需要执行的用例编号,退出输入“0”:"); } while(true); }
public void TestParseWithNullData() { // Arrange var header = new Header { Name = "Root", Depth = -1, From = 0, To = 2, Children = new List <Header> { new Header { Name = "Arrange", Depth = 0, From = 1, To = 1, Children = new List <Header> { new Header { Name = "HttpRequest Actual", Depth = 1, From = 1, To = 1, Children = new List <Header> { new Header { Name = "BaseUri", Depth = 2, From = 1, To = 1, }, } } } }, new Header { Name = "Assertion", Depth = 0, From = 2, To = 2, Children = new List <Header> { new Header { Name = "Uri", Depth = 1, From = 2, To = 2, }, } } } }; // Act TestCaseParser.Parse(header, null, null); }
public void ParseFeaturesTest() { var client = new TFSClient("https://tfs.server.com/collection", "token"); foreach (var test in TestCaseParser.ParseFeatures(Directory.GetFiles(@"C:\Source\...", "*.feature"))) { client.UpdateTestCase(test).Wait(); } }
public void TestParseWithNullRootHeader() { // Arrange var data = new List <List <string> > { new List <string> { "test case 1", "BaseUri", "/local" } }; // Act TestCaseParser.Parse(null, data, null); }
//check read csv file, only right range beacon will read in //check read xml file //check repeat beacon id or repeat beacon name will be ignore void test_readData() { string xml = ".//input//1beacon.xml"; string buff = File.ReadAllText(xml); string[] tags = { "Id", "Version", "BMB_SDDB_distance" }; List <string[]> beaconinfo = new List <string[]> { //Id //Version //BMB_SDDB_distance //BMB_SDDB_distance_cm new string[] { "1", "2", "0.00", "0" }, new string[] { "1", "2", "2048.00", "204800" }, new string[] { "1", "2", "2047.", "204700" }, new string[] { "1", "2", "2047", "204700" }, new string[] { "1", "2", "2047.9", "204790" }, new string[] { "1", "2", "2047.99", "204799" }, new string[] { "1", "2", "2047.990", "204799" }, new string[] { "1", "2", "2047.991" }, new string[] { "1", "2", "2047.9901" }, new string[] { "1", "2", "-0.01" }, new string[] { "1", "2", "2048.01" }, new string[] { "1", "2", "108.00", "10800" }, new string[] { "65535", "2", "108.00", "10800" }, new string[] { "0", "2", "108.00" }, new string[] { "65536", "2", "108.00" }, new string[] { "1", "0", "108.00", "10800" }, new string[] { "1", "255", "108.00", "10800" }, new string[] { "1", "-1", "108.00" }, new string[] { "1", "256", "108.00" }, }; foreach (var b in beaconinfo) { string newbuff = buff; for (int i = 0; i < tags.Length; i++) { newbuff = newbuff.Replace($"{tags[i]}Change", b[i]); } savenewfile(beaconxmlfullname, newbuff); if (b.Length == tags.Length) { Debug.Assert(true == TestCaseParser.RunEndlessTask(1000, RunBFGenInit)); } else { RunBFGenInit(int.Parse(b.Last())); } } File.Delete(beaconxmlfullname); }
public void TestParse() { // Arrange var header = new Header { Name = "Root", Depth = -1, From = 0, To = 2, Children = new List <Header> { new Header { Name = "Arrange", Depth = 0, From = 1, To = 1, Children = new List <Header> { new Header { Name = "HttpRequest Actual", Depth = 1, From = 1, To = 1, Children = new List <Header> { new Header { Name = "BaseUri", Depth = 2, From = 1, To = 1, }, } } } }, new Header { Name = "Assertion", Depth = 0, From = 2, To = 2, Children = new List <Header> { new Header { Name = "Uri", Depth = 1, From = 2, To = 2, }, } } } }; var data = new List <List <string> > { new List <string> { "test case 1", "BaseUri", "/local" } }; // Act var result = TestCaseParser.Parse(header, data, null); // Assert Assert.AreEqual("test case 1", result.Name); Assert.AreEqual(1, result.Assertions.Count); }
public void Sync() { if (_settings.PurgeTestRail) { Purge(); } List <Case> testCases = _testRailClient.GetCases(_settings.ProjectId); _logger.Debug("Found {NumberOfCases} cases for Project {ProjectId}", testCases.Count, _settings.ProjectId); Hierarchy hierarchy = HierarchyLoader .ReadHierarchy(_settings.SpecsFolder) .ToHierarchy(); List <Section> sections = _testRailClient.GetSections(_settings.ProjectId); foreach (var spec in hierarchy.Specifications) { _logger.Verbose("Processing spec {SpecName}", spec.name); var suitePath = spec.SuitePath(); if (!string.IsNullOrEmpty(_settings.BaseSectionPath)) { var basePath = _settings.BaseSectionPath; if (!basePath.EndsWith("/")) { basePath += "/"; } suitePath = basePath + suitePath; } List <Section> suiteSections = CreateSectionsFromSuitePath(suitePath).ToList(); ProcessSuitePath(sections, suiteSections); Section section = suiteSections.Last(); List <int> caseIds = TestCaseParser.ParseTestCaseIds(spec.name).ToList(); Case existingCase = null; if (caseIds.Any()) { existingCase = testCases.FirstOrDefault(c => c.id == caseIds.First()); } if (existingCase != null) { _logger.Verbose("Spec {SpecName} is tied to C{CNumber}", spec.name, caseIds.First()); var cleanSpecName = CleanSpecName(spec.name); if (existingCase.title != cleanSpecName) { existingCase.title = cleanSpecName; _logger.Verbose("Updating {SpecName} in TestRail", spec.name); _testRailClient.UpdateCase(existingCase); } if (existingCase.section_id != section.id) { existingCase.section_id = section.id; _logger.Warning("{SpecName} will need manually moved to Section {@Section} in TestRail. Their API doesn't support moves", spec.name, section); } } else { _logger.Verbose("Adding {SpecName} to TestRail", spec.name); Case newCase = _testRailClient.AddCase(new Case { title = spec.name, section_id = section.id }); _logger.Verbose("Case {@Case} added to TestRail", newCase); var specFile = File.ReadAllText(spec.Filename); specFile = specFile.Replace(spec.name, $"{spec.name} [C{newCase.id}]"); File.WriteAllText(spec.Filename, specFile); } } }