public IActionResult Create(TestRun testRun) { if (ModelState.IsValid) { _context.TestRun.Add(testRun); _context.SaveChanges(); return RedirectToAction("Index"); } ViewData["RunID"] = new SelectList(_context.Run, "RunID", "run", testRun.RunID); ViewData["TestID"] = new SelectList(_context.Test, "TestID", "test", testRun.TestID); return View(testRun); }
private int AddResultOfID(TestRun TestRun, string ResultDirectory, string ScreenshotsDirectory, TestReportDetails TestReportDetails, Test Test, int TestEnvironmentID) { Result result = new Result(); _context.Result.Add(result); result.ResultName = TestReportDetails.TestName; result.ResultDirectory = ResultDirectory; result.ScreenshotsDirectory = ScreenshotsDirectory; result.StoredStatus = TestReportDetails.TestStatus; result.StepsPassed = TestReportDetails.StepsPassed; result.StepsFailed = TestReportDetails.StepsFailed; result.StepsBlocked = TestReportDetails.StepsBlocked; result.StoredStartTime = Convert.ToDateTime(TestReportDetails.strStartTime); result.StoredEndTime = Convert.ToDateTime(TestReportDetails.strEndTime); result.Duration = Convert.ToDateTime(TestReportDetails.Duration); result.StoredBrowser = TestReportDetails.Browser; result.TestRunID = TestRun.TestRunID; result.StoredTestID = Test.TestID; result.StoredTestName = Test.Name; if (Test.TestDataSource == "Excel") { var ExcelFilename = Test.ExcelFilePath; result.StoredTestDataFileName = ExcelFilename; var TestDataFilePath = Path.Combine(_environment.WebRootPath, "uploads", "tests", Test.TestID.ToString(), ExcelFilename); var testDirectory = Path.Combine(ResultDirectory, "test"); Directory.CreateDirectory(testDirectory); var StoredTestDataFilePath = Path.Combine(testDirectory, ExcelFilename); System.IO.File.Copy(TestDataFilePath, StoredTestDataFilePath); result.StoredTestDataFileContentType = Test.ContentType; } var environmentDirectory = Path.Combine(ResultDirectory, "environment"); Directory.CreateDirectory(environmentDirectory); TestEnvironment testEnvironment = _context.TestEnvironment.Single(t => t.TestEnvironmentID == TestEnvironmentID); result.StoredTestEnvironmentID = TestEnvironmentID; var TestEnvironmentFileName = testEnvironment.XMLFilePath; result.StoredTestEnvironmentFileName = TestEnvironmentFileName; result.StoredTestEnvironmentName = testEnvironment.Name; var EnvironmentDataFilePath = Path.Combine(_environment.WebRootPath, "uploads", "environments", TestEnvironmentID.ToString(), TestEnvironmentFileName); var StoredEnvironmentFilePath = Path.Combine(environmentDirectory, TestEnvironmentFileName); System.IO.File.Copy(EnvironmentDataFilePath, StoredEnvironmentFilePath); result.StoredTestEnvironmentFileContentType = testEnvironment.ContentType; result.StoredTestRunnerID = TestRun.TestRunner.Value; result.StoredTestRunnerName = _context.TestRunner.Single(t => t.TestRunnerID == TestRun.TestRunner.Value).Name; _context.SaveChanges(); return result.ResultID; }
public IActionResult StopAllTestsNow(string AllTestRunIDs, int? id) { var TestRunIDArray = AllTestRunIDs.Split(','); TestRun testRun = new TestRun(); foreach (var testRunID in TestRunIDArray) { testRun = _context.TestRun.Single(t => t.TestRunID == Convert.ToInt32(testRunID)); if(testRun.Status != "Passed") { testRun.RetriesLeft = null; testRun.Status = "Unassigned"; _context.Update(testRun); } } _context.SaveChanges(); HttpContext.Session.SetString("Message", "All tests set to stop"); return RedirectToAction("Details", new RouteValueDictionary(new { controller = "Runs", action = "Details", ID = id })); }
public IActionResult RunRemainingTestsNow(string AllTestRunIDs, int? id) { var TestRunIDArray = AllTestRunIDs.Split(','); var time = DateTime.Now; TestRun testRun = new TestRun(); foreach (var testRunID in TestRunIDArray) { testRun = _context.TestRun.Single(t => t.TestRunID == Convert.ToInt32(testRunID)); var status = testRun.Status; if(status == "Unassigned" || status == "Failed" || status == "Blocked" || status == "Waiting" || status == "Running") { testRun.Status = StatusForTestRunBasedOnDependencies(Convert.ToInt32(testRunID)); testRun.StartTime = time; if (testRun.Retries != null) { testRun.RetriesLeft = testRun.Retries; } _context.Update(testRun); } } _context.SaveChanges(); HttpContext.Session.SetString("Message", "All remaining tests set to run"); return RedirectToAction("Details", new RouteValueDictionary(new { controller = "Runs", action = "Details", ID = id })); }
public IActionResult Edit(TestRun testRun) { if (testRun.TestRunnerGroupID == -1) { testRun.TestRunnerGroupID = null; } if (ModelState.IsValid) { _context.Update(testRun); if(testRun.DependencyGroupID == 0) { testRun.DependencyGroupID = null; } _context.SaveChanges(); } HttpContext.Session.SetString("Message", "Test Run ID " + testRun.TestRunID.ToString() + " successfully edited"); return RedirectToAction("Details", new RouteValueDictionary(new { controller = "Runs", action = "Details", ID = testRun.RunID })); }
public ActionResult LinkTestsToRuns(IFormCollection form) { Run run = _context.Run.Single(m => m.RunID == Convert.ToInt32(form["id"])); if(run == null) { return HttpNotFound(); } List<string> usersListOfTests = form["Run.Tests"].ToList(); string TestRunCreationMessage = "TestRuns created for: " + System.Environment.NewLine; int TestEnvironmentID = Convert.ToInt32(form["TestRun.TestEnvironmentID"]); List<string> BrowserList = form["TestRun.Browser"].ToList(); string Status = form["Status"]; string ResultFile = form["ResultFile"]; foreach (string testID in usersListOfTests) { foreach (string Browser in BrowserList) { TestRun testRun = new TestRun(); Test test = _context.Test.Single(t => t.TestID == Convert.ToInt32(testID)); testRun.RunID = run.RunID; testRun.TestID = test.TestID; testRun.TestEnvironmentID = TestEnvironmentID; testRun.Browser = Browser; testRun.Status = Status; _context.TestRun.Add(testRun); TestRunCreationMessage = TestRunCreationMessage + "Test: " + test.Name + " & Run: " + run.Name + System.Environment.NewLine; } } _context.SaveChanges(); HttpContext.Session.SetString("Message", TestRunCreationMessage); if (ModelState.IsValid) { return RedirectToAction("Details", new RouteValueDictionary(new { controller = "Runs", action = "Details", ID = Convert.ToInt32(form["id"]) })); } return RedirectToAction("Details", new RouteValueDictionary(new { controller = "Runs", action = "Details", ID = Convert.ToInt32(form["id"]) })); }