public Api(TestExecutioner te, HttpClientHandler handler, string baseUrl)
        {
            TE = te;
            if (string.IsNullOrEmpty(baseUrl))
            {
                baseUrl = Config.GetConfigSetting("ApiUrl", "");
            }

            Client             = new(handler);
            Client.BaseAddress = new Uri(baseUrl);
        }
        public Api(TestExecutioner te, string baseUrl = "", string appType = "application/json")
        {
            TE = te;
            ApplicationType = appType;
            if (string.IsNullOrEmpty(baseUrl))
            {
                baseUrl = Config.GetConfigSetting("ApiUrl", "");
            }

            Client             = new();
            Client.BaseAddress = new Uri(baseUrl);
            Client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue(ApplicationType));
        }
        private void AddSkippedResult(TestExecutioner te, string testKey)
        {
            var start  = te.StartTime.ToString("yyyy-MM-dd'T'HH:mm:ssK");
            var end    = te.DisposeTime == null ? DateTime.Now : (DateTime)te.DisposeTime;
            var finish = end.ToString("yyyy-MM-dd'T'HH:mm:ssK");

            var comment = $"Total Runtime: {end.Subtract(te.StartTime).ToString().Split('.')[0]} (hh:mm:ss)" + Environment.NewLine;

            comment += "This test was skipped because " + te.NUnitResult.Outcome.Label;

            var info = new
            {
                finishDate = DateTime.Now.ToString("yyyy-MM-dd'T'HH:mm:ssK"),
            };

            //generate this from each test object we get

            var test = new
            {
                testKey,
                start,
                finish,
                comment,
                status = "SKIPPED"
            };

            var body = new
            {
                testExecutionKey = ExecutionKey,
                info,
                tests = new object[] { test }
            };

            dynamic rsp;

            lock (Locker)
            {
                Wait();
            }
            rsp = ApiObj.PostCall(Endpts.ImportResults, body, "");

            //check upload????????
            if (Convert.ToString((object)rsp).ToLower().Contains("error"))
            {
                try
                {
                    Console.WriteLine(Convert.ToString((object)rsp));
                }
                catch { }
            }
        }
        public PMSApplication(TestCaseHeaderData headerData, string userName = "", string password = "")
        {
            executioner = TestExecutionerPool.GetTestExecutioner(headerData, userName, password, landingPage);

            if (!executioner.PoolState.WasAlreadyInPool)
            {
                executioner.NavigateTo(loginURL, "Navigate to Patitnet management system's login page");

                if (!(string.IsNullOrEmpty(userName) && string.IsNullOrEmpty(password)))
                {
                    this.IsAuthenticated = AuthFeature.LoginToPMS(userName, password);
                }
            }
        }
        public void AddTestResult(TestExecutioner te, string testName)
        {
            te.FailLastStepIfFailureNotTriggered();

            var testCase = FindTestCase(testName, te);

            if (te.NUnitResult.Outcome.Status.ToString().Equals("Skipped"))
            {
                AddSkippedResult(te, testCase.IssueKey);
                return;
            }

            AddTestToTestRun(testCase.IssueId);
            AddTestResults(te, testCase.IssueKey);
        }
        public PMSApplication(string testNumber, string testName = "", string testDescription = "", string testFamily = "", string userName = "", string password = "")
        {
            TestCaseHeaderData tcHeader = new TestCaseHeaderData()
            {
                TestName        = string.Format("{0}_{1}", testNumber, testName.Replace(" ", "_")),
                TestNumber      = testNumber,
                TestDescription = testDescription
            };

            executioner = TestExecutionerPool.GetTestExecutioner(tcHeader, userName, password, landingPage);

            if (!executioner.PoolState.WasAlreadyInPool)
            {
                executioner.NavigateTo(loginURL, "Navigate to Patitnet management system's login page");

                if (!(string.IsNullOrEmpty(userName) && string.IsNullOrEmpty(password)))
                {
                    this.IsAuthenticated = AuthFeature.LoginToPMS(userName, password);
                }
            }
        }
        private XRayTest FindTestCase(string testName, TestExecutioner te)
        {
            var  testSteps = te.RecordedSteps;
            bool hasTest   = Tests.Any(x => x.Name.ToLower().Trim().Equals(testName.ToLower().Trim()));

            if (hasTest)
            {
                var test = Tests.First(x => x.Name.Trim().Equals(testName.Trim()));

                if (!te.TestCaseFailed)
                {
                    UpdateTestCase(testName, test, testSteps);
                }

                return(test);
            }
            else
            {
                return(CreateTestCase(testName, testSteps));
            }
        }
示例#8
0
 public AssertHelp(TestExecutioner tE)
 {
     TE = tE;
 }
 public HospitalProvisioningFeature(TestExecutioner executioner)
 {
     this.testExecutioner   = executioner;
     base.navigationFeature = new NavigationFeature(executioner);
 }
示例#10
0
        //TODO add & improve assertions at this level
        //this will require a class for customized assertions to track

        public ElementActions(TestExecutioner tE)
        {
            TE     = tE ?? throw new ArgumentNullException(nameof(tE));
            Driver = TE.RawSeleniumWebDriver_AvoidCallingDirectly;
        }
        private void AddTestResults(TestExecutioner te, string testKey)
        {
            var start  = te.StartTime.ToString("yyyy-MM-dd'T'HH:mm:ssK");
            var end    = te.DisposeTime == null ? DateTime.Now : (DateTime)te.DisposeTime;
            var finish = end.ToString("yyyy-MM-dd'T'HH:mm:ssK");
            var status = te.TestCaseFailed ? "FAILED" : "PASSED";

            var comment = $"*Total Runtime:* {end.Subtract(te.StartTime).ToString().Split('.')[0]} (hh:mm:ss)";

            if (te.TestCaseFailed)
            {
                if (te.TestAuthor.ReportedBugs.Count > 0)
                {
                    var bugBase = Config.GetConfigSetting("BugLinkBase", "");
                    var list    = new List <string>();
                    te.TestAuthor.ReportedBugs.ForEach(r => list.Add($"[{r}|{bugBase}{r}]"));
                    status   = "BUGGED";
                    comment += Environment.NewLine + "*Likely failing due to bug(s):* " + string.Join(", ", list);
                }

                comment += Environment.NewLine + "*Step Failures:*";
                var index = 0;
                foreach (var step in te.RecordedSteps)
                {
                    index++;
                    if (!step.StepPassed)
                    {
                        comment += Environment.NewLine + $"Step {index}: {step.StepDescription.Replace("\\", "-")}   Expected: {step.ExpectedResult}   Actual: {step.ActualResult}";
                    }
                }

                comment += Environment.NewLine + "*StackTrace:*" + Environment.NewLine + te.TestStackTrace;
            }

            var info = new
            {
                finishDate = DateTime.Now.ToString("yyyy-MM-dd'T'HH:mm:ssK"),
            };

            //generate this from each test object we get

            var test = new
            {
                testKey,
                start,
                finish,
                comment,
                status,
                steps = GenerateTestSteps(te.RecordedSteps, out _, te.TestCaseFailed)
            };

            var body = new
            {
                testExecutionKey = ExecutionKey,
                info,
                tests = new object[] { test }
            };

            byte[] img;
            if (te.TestCaseFailed)
            {
                for (int i = te.RecordedSteps.Count; i > 0; i--)
                {
                    if (te.RecordedSteps[i - 1].ImageData != null)
                    {
                        var rand = new RandomTestData();
                        img = te.RecordedSteps[i - 1].ImageData;

                        var test2 = new
                        {
                            test.testKey,
                            test.start,
                            test.finish,
                            test.comment,
                            evidence = new[]
                            {
                                new
                                {
                                    data        = Convert.ToBase64String(img),
                                    filename    = $"{rand.GetRandomAlphaNumericString(50)}.png",
                                    contentType = "image/png"
                                }
                            },
                            test.status,
                            test.steps
                        };

                        body = new
                        {
                            testExecutionKey = ExecutionKey,
                            info,
                            tests = new object[] { test2 }
                        };
                        break;
                    }
                }
            }


            dynamic rsp;

            lock (Locker)
            {
                Wait();
                //rsp = ApiObj.PostCall(Endpts.ImportResults, body, "");
            }
            rsp = ApiObj.PostCall(Endpts.ImportResults, body, "");

            //check upload????????
            if (Convert.ToString((object)rsp).ToLower().Contains("error"))
            {
                try
                {
                    Console.WriteLine(Convert.ToString((object)rsp));
                }
                catch { }
            }
        }
示例#12
0
 public ElementResult(TestExecutioner tE)
 {
     TE = tE;
 }
 public NavigationFeature(TestExecutioner executioner)
 {
     this.executioner = executioner;
 }
示例#14
0
        static void Main(string[] args)
        {
            /*//test annealing
             * Console.WriteLine("AlgBattle - algorithms comparison in QAP problem");
             * var qapDataReader = new QapDataFileReader();
             * var data = qapDataReader.ReadData(@"Data/BaseData/tai60a.dat");
             * var solution = qapDataReader.ReadSolution(@"Data/BaseData/tai60a.sln");
             * var bench = new QapSolutionBenchmark();
             * LocalOptimumValidator validator = new LocalOptimumValidator();
             * Console.WriteLine($"Optimal::: {string.Join(" ", solution.Solution)}");
             * Console.WriteLine($"Fitness:::: {solution.Score}");
             * Console.WriteLine($"Fitness Ours:::: {bench.RateSolutionIndexedFromZero(solution.Solution.ToArray(), data)}");
             * Console.WriteLine($"Is local optimum::: {validator.CheckLocalOptimum(solution.Solution.ToArray(), data, true)}");
             * Stopwatch sw = new Stopwatch();
             * sw.Start();
             * var randomSolver = new QapRandomSolver(data);
             * var randomSolution = randomSolver.GetSolution();
             * Console.WriteLine($"Random:::: {string.Join(" ", randomSolution)}");
             * Console.WriteLine($"Fitness:::: {bench.RateSolution(randomSolution, data)}");
             * Console.WriteLine($"Is local optimum::: {validator.CheckLocalOptimum(randomSolution, data, false)}");
             *
             * var annealingSolver = new QapAnnealingSolver(data);
             * var annealingSolution = annealingSolver.GetSolution();
             * Console.WriteLine($"Annealing:: {string.Join(" ", annealingSolution)}");
             * Console.WriteLine($"Fitness:::: {bench.RateSolution(annealingSolution, data)}");
             * Console.WriteLine($"Is local optimum::: {validator.CheckLocalOptimum(annealingSolution, data, false)}");
             *
             * var tabuSolver = new QapTabuSolver(data);
             * var tabuSolution = tabuSolver.GetSolution();
             * Console.WriteLine($"Tabu:: {string.Join(" ", tabuSolution)}");
             * Console.WriteLine($"Fitness:::: {bench.RateSolution(tabuSolution, data)}");
             * Console.WriteLine($"Is local optimum::: {validator.CheckLocalOptimum(tabuSolution, data, false)}");
             *
             * var heuristicSolver = new QapHeuristicSolver(data);
             * var heuristicSolution = heuristicSolver.GetSolution();
             * Console.WriteLine($"Heurstic:: {string.Join(" ", heuristicSolution)}");
             * Console.WriteLine($"Fitness:::: {bench.RateSolution(heuristicSolution, data)}");
             * Console.WriteLine($"Is local optimum::: {validator.CheckLocalOptimum(heuristicSolution, data, false)}");
             *
             *
             * var steepestSolver = new QapSteepestLocalSolver(data);
             * var steepestSolution = steepestSolver.GetSolution();
             * Console.WriteLine($"Steepest:: {string.Join(" ", steepestSolution)}");
             * Console.WriteLine($"Fitness:::: {bench.RateSolution(steepestSolution, data)}");
             * Console.WriteLine($"Is local optimum::: {validator.CheckLocalOptimum(steepestSolution, data, false)}");
             *
             * var greedySolver = new QapGreedyLocalSolver(data);
             * var greedySolution = greedySolver.GetSolution();
             * Console.WriteLine($"Greedy:: {string.Join(" ", greedySolution)}");
             * Console.WriteLine($"Fitness:::: {bench.RateSolution(greedySolution, data)}");
             * Console.WriteLine($"Is local optimum::: {validator.CheckLocalOptimum(greedySolution, data, false)}");
             *
             * sw.Stop();
             * Console.WriteLine($"Elapsed medium time: {sw.Elapsed }");
             * Console.ReadLine();
             */
            //instancje do analizy
            // chr25a - duze roznice random vs reszta, naiwne niezle
            IList <string> taiNames = new List <string> {
                "tai15b", "tai20b", "tai25b", "tai30b", "tai35b", "tai40b", "tai50b", "tai60b", "tai80b"
            };
            var test     = new TestExecutioner();
            var timerAll = new Stopwatch();

            timerAll.Start();
            test.RunTest(20, "taiOutput", taiNames);
            timerAll.Stop();
            Console.WriteLine(timerAll.Elapsed.Milliseconds);


            //////////////optimal list

            /*IList<string> taiNames = new List<string> { "tai15b", "tai20b", "tai25b", "tai30b", "tai35b", "tai40b", "tai50b", "tai60b", "tai80b" };
             * List<ulong> list = new List<ulong>();
             * foreach (string name in taiNames)
             * {
             *  var qapDataReader = new QapDataFileReader();
             *  var data = qapDataReader.ReadData(@"../AlgBattle/Data/BaseData/" + name + ".dat");
             *  var optimalSolution = qapDataReader.ReadSolution(@"../AlgBattle/Data/BaseData/" + name + ".sln");
             *  list.Add((ulong)optimalSolution.Score);
             * }
             * using (StreamWriter file = File.AppendText("optimal_solutions"))
             * {
             *  foreach (ulong line in list)
             *  {
             *      file.WriteLine(line + ';');
             *  }
             * }*/

            ////////// test first vs last result "tai15b", "tai20b", "tai25b", "tai30b", "tai35b",, "chr20b", "els19", "esc16a", "esc16j"

            /*IList<string> taiNames = new List<string> { "bur26f", "tai15b", "chr12b", "chr20a", "esc16j"};
             * foreach (string name in taiNames){
             *  FirstVsLastResultTester test = new FirstVsLastResultTester(name, 300);
             *  test.run();
             * }*/

            ////////// test repeating

            /*IList<string> taiNames2 = new List<string> { "tai15a", "tai20b", "chr12a" };
             * foreach (string name in taiNames2)
             * {
             *  RepeatingTest test = new RepeatingTest(name, 200);
             *  test.run();
             * }*/

            //IList<string> taiNames = new List<string> { "tai30b", "chr22b", "lipa50b"};
            //for(int i = 0; i <10; i++)
            //{
            //    foreach (string name in taiNames)
            //    {
            //        EfficiencyMeter test = new EfficiencyMeter();
            //        test.MaxRepetitionsWithoutImprove = 150;
            //        test.InstanceName = name;
            //        test.run();
            //    }
            //}

            /*IList<string> taiNames = new List<string> { "tai30b", "chr22b", "lipa50b" };
             * foreach (string name in taiNames)
             * {
             *  EfficiencyMeter test = new EfficiencyMeter();
             *  test.MaxRepetitionsWithoutImprove = 150;
             *  test.InstanceName = name;
             *  test.Repetitions = 10;
             *  test.run();
             * }     */
        }
示例#15
0
 public AuthenticationFeature(TestExecutioner testExectioner)
 {
     this.executioner = testExectioner;
 }
 public HospitalListScreenScrapper(TestExecutioner executioner)
 {
     this.executioner = executioner;
 }