/// <summary> /// Update testcases /// </summary> /// <param name="testRepository"></param> /// <param name="testCaseList"></param> private void UpdateTestCases (ITestCaseRepository <TestCaseModel> testRepository, IList <TestCaseModel> testCaseList) { foreach (TestCaseModel testCaseModel in testCaseList) { TestCaseModel caseModel = testRepository.GetByName(testCaseModel.TestCaseName); if (caseModel != null) { if (testCaseModel.TestCategory != caseModel.TestCategory || testCaseModel.TestCaseDescription != caseModel.TestCaseDescription || testCaseModel.TestCasePriority != caseModel.TestCasePriority || testCaseModel.DependentTestCaseName != caseModel.DependentTestCaseName || testCaseModel.Order != caseModel.Order || testCaseModel.IsActive != caseModel.IsActive) { testRepository.GetId(testCaseModel.TestCaseName); UpdateResult result = testRepository.Update(testCaseModel); if (result.IsAcknowledged) { Logger.log.Debug("TestCase is updataed Successfully:" + testCaseModel.TestCaseName); } else { throw new MongoException("Updating of testCase failed:" + testCaseModel.TestCaseName); } } } } }
public ActionResult GenerateCodeUnitTest(TestCaseModel model) { try { if (model != null) { Parallel.ForEach(model.testGenerateCodes.testCases, data => { data.testCaseStatus = GenerateCodeTestCaseResultsResponse(data); }); if (model != null) { return(Ok(new ApiOkResponse(model))); } else { return(StatusCode(StatusCodes.Status500InternalServerError, new ApiResponse(500, null))); } } else { return(StatusCode(StatusCodes.Status500InternalServerError, new ApiResponse(500, null))); } } catch (Exception ex) { ex.ToString(); return(StatusCode(StatusCodes.Status500InternalServerError, new ApiResponse(500, null))); } }
/// <summary> /// Is dependent testcase is executed /// </summary> /// <param name="testCaseName"></param> /// <returns></returns> private bool IsDependentTestCaseExecuted(string testCaseName) { bool isDependencyTestCaseExecuted = false; ITestCaseRepository <TestCaseModel> testCaseRepository = mongoRepository.GetTestCaseRepository; TestCaseModel testCaseModel = testCaseRepository.GetByName(testCaseName); if (testCaseModel.DependentTestCaseName != null) { ObjectId objectId = testCaseRepository.GetId(testCaseModel.DependentTestCaseName); if (objectId != null) { TestResultModel testResultModel = mongoRepository.GetTestResultRepository .GetTestResultsByTestCaseId(objectId) .FirstOrDefault(); if (testResultModel.Result.Equals(TestResult.Passed.ToString())) { isDependencyTestCaseExecuted = true; } } } else { isDependencyTestCaseExecuted = true; } return(isDependencyTestCaseExecuted); }
public List<TestCaseModel> GetTestCases() { // Get sections from TestRail var sections = GetSections().ToList(); // Get test cases from TestRail var testCasesJson = (JArray)SendRequest(_testRailApiClient.SendGet, "get_cases/" + _testRailProjectId, null); // Convert JArray to concrete list var testCases = new List<TestCaseModel>(); foreach (var testCaseJson in testCasesJson) { var sectionId = (int)testCaseJson["section_id"]; var section = sections.First(s => s.Id == sectionId); var testCase = new TestCaseModel { Id = (int)testCaseJson["id"], Title = (string)testCaseJson["title"], FixtureName = (string)testCaseJson["custom_feature_name"], IsAutomated = (bool)testCaseJson["custom_is_automated"], TypeId = (int)testCaseJson["type_id"], SectionId = sectionId, Section = section, RootSectionId = section.RootSectionId }; testCases.Add(testCase); } return testCases; }
public void LoadCode(TestCaseModel caseModel, bool bReadonly = false, bool bAutoLoadHighlight = false, bool bAutoDetectHighlight = false) { if (caseModel != null) { m_SourceData = caseModel; try { using (Stream stream = new MemoryStream()) { XmlDocument doc = new XmlDocument(); TextReader textReader = new StringReader(caseModel.TextValue); doc.Load(textReader); XmlNode node = (XmlNode)doc.DocumentElement; XmlAttribute nameAttr = node.Attributes["Name"]; nameAttr.Value = caseModel.GetFinalName(); XmlAttribute classAttr = node.Attributes["Class"]; classAttr.Value = caseModel.ParentNodedata.GetFinalName(); caseModel.TextValue = ConvertXmlToString(doc); } } catch (Exception) { } textEditorControl1.Text = caseModel.TextValue; } if (bReadonly) { textEditorControl1.ReadOnly = true; } //richEditControl1.LoadDocument(stream, DocumentFormat.Rtf); //richEditControl1.Document.Sections[0].Page.Width = 10000; }
public ActionResult TestCase(string number) { var model = new TestCaseModel(); model.TestCase = _requirementsStore.GetTest(number); return(View(model)); }
public static void FirstScenario(TestCaseModel testCase) { IWebDriver browserObject = testCase.getBrowserObject(); SearchModel searchInputs = testCase.GetSearchModel(); openTargetURL(browserObject, testCase.getURL()); searchInputs = searchAction_HomePage(browserObject, searchInputs); }
private TestCaseModel AddTestCase(TestCaseModel testCase) { var id = GetUniqRandomId(_testCases.Cast <BaseModel>().ToArray()); testCase.ID = id.ToString(); _testCases.Add(testCase); return(testCase); }
public async Task <TestCaseDto> Add(TestCaseModel model) { var content = new StringContent(JsonConvert.SerializeObject(model), Encoding.UTF8, "application/json"); var response = await _httpClient.PostAsync("http://localhost:5000/api/testCase", content); var result = await response.Content.ReadAsStringAsync(); return(JsonConvert.DeserializeObject <TestCaseDto>(result)); }
public ActionResult Save(TestCaseModel model) { var old = Repository.GetTestCase(model.ID); model.Folder = Repository.GetFolder(model.Folder.ID); model = Repository.UpdateTestCase(model); Repository.UpdateTestCase(model); return(RedirectToAction("ViewTc", new { testCaseId = model.ID })); }
public void TestMatchesOther(int typeId, bool isAutomated, bool shouldMatch) { var test = new TestCaseModel { TypeId = 1, IsAutomated = true }; var testOther = new TestCaseModel { TypeId = typeId, IsAutomated = isAutomated }; test.MatchesOther(testOther).Should().Be(shouldMatch); }
public static void TestCaseController(TestCaseModel testCase) { testCase.setSearchModel(SearchModelController.createSearchModel()); if (testCase.getScenario().Equals("Scenario1")) { TestScenarios.FirstScenario(testCase); } else if (testCase.getScenario().Equals("Scenario2")) { TestScenarios.SecondScenario(testCase); } }
public TestCaseModel UpdateTestCase(TestCaseModel testCase) { var index = _testCases.FindIndex(x => x.ID.Equals(testCase.ID)); if (index == -1) { _testCases.Add(testCase); } else { _testCases[index] = testCase; } return(testCase); }
public async Task <ActionResult <TestCaseDto> > Post([FromBody] TestCaseModel model) { if (ModelState.IsValid) { var testCase = await _testCaseService.AddTestCaseAsync(model.Name, model.Description, model.ExpectedResult, model.ProjectId, model.SuitId, model.Steps); return(Created("", testCase)); } return(BadRequest()); }
public void TestToDict() { var test = new TestCaseModel { Title = "Test Case 1", TypeId = 1, IsAutomated = true }; var dict = new Dictionary <string, object> { ["title"] = "Test Case 1", ["type_id"] = 1, ["custom_is_automated"] = true }; test.ToDict().Should().BeEquivalentTo(dict); }
public static void Draw_UserChoosingScenarios(TestCaseModel TestCase) { Console.WriteLine("Please, read the below scenarios and select your targetted one.\n"); Console.WriteLine("\t 1-" + TestData.TestData.TestingScenarios["1"] + "\n"); Console.WriteLine("\t 2-" + TestData.TestData.TestingScenarios["2"] + "\n"); Console.WriteLine("Your choice number (1 or 2): "); string selection = Console.ReadLine(); if (InputController.Validate_ScenarioSelection(selection)) { TestCase.setScenario(TestData.TestData.TestingScenarios[selection]); TestController.TestCaseController(TestCase); } else { DrawMainConsole_InvalidInput(); Draw_UserChoosingScenarios(TestCase); } }
public TestCaseModel UpdateTestCase(TestCaseModel testCase) { if (string.IsNullOrEmpty(testCase.ID)) { return(AddTestCase(testCase)); } var index = _testCases.FindIndex(x => x.ID.Equals(testCase.ID)); if (index == -1) { testCase = AddTestCase(testCase); } else { _testCases[index] = testCase; } return(testCase); }
public static void Draw_UserChoosingURL(TestCaseModel TestCase) { Console.Clear(); Console.WriteLine("Your browser invoking process completed successfully.\n"); Console.WriteLine("Please read the below URL and select your targetted one.\n"); Console.WriteLine("\t 1-" + TestData.TestData.TestingURLs["1"] + "\n"); Console.WriteLine("\t 2-" + TestData.TestData.TestingURLs["2"] + "\n"); Console.WriteLine("Your choice number (1 or 2): "); string selection = Console.ReadLine(); if (InputController.Validate_URLSelection(selection)) { TestCase.setURL(TestData.TestData.TestingURLs[selection]); Draw_UserChoosingScenarios(TestCase); } else { DrawMainConsole_InvalidInput(); Draw_UserChoosingURL(TestCase); } }
public void TestMatchTestRailCaseToNunitCase(string fixtureName, string title, bool shouldMatch) { var nunitTestCase = new TestCaseModel { FixtureFullName = "Specs.Features.Account", FixtureName = fixtureName, Title = title, Tags = "regression,automated", IsAutomated = true, TypeId = 1, }; var matchingCase = _testSyncController.MatchTestRailCaseToNunitCase(_testRailCases, nunitTestCase); if (shouldMatch) { matchingCase.Should().Be(_testRailCases[1]); } else { matchingCase.Should().BeNull(); } }
// ======================================================================== // Methods #region === Methods /// <summary> /// Loads the test cases at the specified directory. /// </summary> public void LoadTestCases() { TestCaseModel.LoadTestCases(Settings.Default.TestCaseDirectory); }
// ======================================================================== // Con- / Destructors #region === Con- / Destructors /// <summary> /// Initializes a new instance of <see cref="CoreData"/>. /// </summary> private CoreData() { Messages = new ObservableCollection <Message>(); TestCaseModel = new TestCaseModel(); }
public void DeleteTestCase(TestCaseModel testCase) { _testCases.Remove(testCase); }
private void button1_Click(object sender, EventArgs e) { Console.WriteLine(Directory.GetCurrentDirectory()); String dir = Directory.GetCurrentDirectory(); //Process p = new Process(); //p.StartInfo.FileName = "nunit3-console.exe NTesting.dll"; //p.Start(); Process.Start("nunit3-console.exe", "NTesting2.dll").WaitForExit(); if (File.Exists("TestResult.xml")) { Console.WriteLine("Datei ist vorhanden"); XmlReader reader = XmlReader.Create("TestResult.xml"); bool inTestCase = false; List <TestCaseModel> cases = new List <TestCaseModel>(); TestCaseModel m; while (reader.Read()) { if ((reader.NodeType == XmlNodeType.Element) && (reader.Name == "test-run")) { Console.WriteLine("ID: {0} RESULT: {1} TOTAL: {2} PASSED: {3} FAILED: {4}", reader.GetAttribute("id"), reader.GetAttribute("result"), reader.GetAttribute("total"), reader.GetAttribute("passed"), reader.GetAttribute("failed")); } if ((reader.NodeType == XmlNodeType.Element) && (reader.Name == "test-case")) { m = new TestCaseModel(); m.id = reader.GetAttribute("id"); m.name = reader.GetAttribute("name"); m.fullname = reader.GetAttribute("fullname"); m.methodname = reader.GetAttribute("methodname"); m.classname = reader.GetAttribute("classname"); m.runstate = reader.GetAttribute("runstate"); m.seed = reader.GetAttribute("seed"); m.result = reader.GetAttribute("result"); m.startTime = reader.GetAttribute("start-time"); m.endTime = reader.GetAttribute("end-time"); m.duration = reader.GetAttribute("duration"); m.asserts = reader.GetAttribute("asserts"); inTestCase = true; cases.Add(m); } if ((reader.NodeType == XmlNodeType.Element) && (reader.Name == "message")) { if (inTestCase) { TestCaseModel lastItem = cases.Last <TestCaseModel>(); lastItem.message = reader.ReadElementContentAsString(); inTestCase = false; reader.Read(); lastItem.stacktrace = reader.ReadElementContentAsString(); } } if ((reader.NodeType == XmlNodeType.Element) && (reader.Name == "test-suite")) { inTestCase = false; } } reader.Close(); Console.WriteLine("Anzahl cases: {0}", cases.Count); dataGridView1.DataSource = cases; } }
public ActionResult Save(TestCaseModel model) { model = Repository.UpdateTestCase(model); return(RedirectToAction("ViewTc", new { testCaseId = model.ID })); }
public TestCaseModel MatchTestRailCaseToNunitCase(List <TestCaseModel> testRailCases, TestCaseModel nunitTestCase) { return(testRailCases.Find(trCase => trCase.Section.Name + trCase.Title == nunitTestCase.FixtureName + nunitTestCase.Title)); }
public static void SecondScenario(TestCaseModel testCase) { IWebDriver browserObject = testCase.getBrowserObject(); openTargetURL(browserObject, testCase.getURL()); }
public List <TestCaseModel> GetTestsFromNunit3File(string xmlFilePath, List <TestCaseTypeModel> testCaseTypes) { var testCases = new List <TestCaseModel>(); // Load the XML file var doc = new XmlDocument(); doc.Load(xmlFilePath); // Get test fixtures var testFixtureNodes = doc.SelectNodes("//test-suite[@type='TestFixture']"); foreach (XmlNode testFixtureNode in testFixtureNodes) { // Get test fixture name var fixtureDesc = testFixtureNode.SelectSingleNode("./properties/property[@name='Description']")?.Attributes["value"]?.InnerText; var fixtureName = testFixtureNode.Attributes["name"]?.InnerText; var testFixtureName = fixtureDesc ?? fixtureName; var fixtureFullName = testFixtureNode.Attributes["fullname"]?.InnerText.Replace($".{fixtureName}", ""); var fixtureCategories = GetTestCaseCategories(testFixtureNode); // Get test cases (non-parameterized) var testCaseNodes = testFixtureNode.SelectNodes("./test-case"); foreach (XmlNode testCaseNode in testCaseNodes) { // Get categories var tcCategories = GetTestCaseCategories(testCaseNode); tcCategories.AddRange(fixtureCategories); // Create model and add to list var testCase = new TestCaseModel { FixtureName = testFixtureName, Title = GetTestCaseName(testCaseNode), Tags = string.Join(",", tcCategories), FixtureFullName = fixtureFullName, TestResult = GetTestResult(testCaseNode) }; testCases.Add(testCase); } // Get test cases (parameterized) var testSuiteParameterizedNodes = testFixtureNode.SelectNodes("./test-suite[@type='ParameterizedMethod']"); foreach (XmlNode testSuiteParameterizedNode in testSuiteParameterizedNodes) { // Get categories var tcpCategories = GetTestCaseCategories(testSuiteParameterizedNode); tcpCategories.AddRange(fixtureCategories); // Iterate through parameterized test cases var testSuiteParameterizedTestCases = testSuiteParameterizedNode.SelectNodes("./test-case"); foreach (XmlNode testSuiteParameterizedTestCase in testSuiteParameterizedTestCases) { var testCaseParameterized = new TestCaseModel { FixtureName = testFixtureName, Title = GetTestCaseName(testSuiteParameterizedTestCase), Tags = string.Join(",", tcpCategories), FixtureFullName = fixtureFullName, TestResult = GetTestResult(testSuiteParameterizedTestCase) }; testCases.Add(testCaseParameterized); } } } // Final formatting for test cases foreach (var t in testCases) { // Sort the tags var tags = t.Tags.Split(',').OrderBy(tag => tag).ToList(); t.Tags = string.Join(",", tags); // Make sure Title doesn't exceed max length in TestRail if (t.Title.Length > 250) { t.Title = t.Title.Substring(0, 250); } // Case Type TestCaseTypeModel associatedCaseType = null; foreach (var tag in tags) { associatedCaseType = testCaseTypes.Find(x => x.Name.ToLower().Equals(tag)); if (associatedCaseType != null) { break; } } associatedCaseType = associatedCaseType ?? testCaseTypes.First(x => x.IsDefault); t.TypeId = associatedCaseType.Id; // Is Automated t.IsAutomated = tags.Contains("automated"); } return(testCases); }