Exemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name=""></param>
        /// <returns></returns>
        public static string NormalizeBrowserName(TestSuites driver)
        {
            switch (driver)
            {
            case TestSuites.CHROME:
                return("Chrome");

            case TestSuites.EDGE:
                return("Edge");

            case TestSuites.FIREFOX:
                return("FireFox");

            case TestSuites.INTERNETEXPLORER:
                return("Internet Explorer");

            case TestSuites.PHANTOMJS:
                return("PhantomJS");

            case TestSuites.SAFARI:
                return("Safari");

            default:
                return("Unsupported browser specified in NormalizeBrowserName");
            }
        }
Exemplo n.º 2
0
        public async Task<TestSuites> Execute()
        {
            TestSuites res = null;
            _isRunning = true;
            var authHandler = AuthManager.Instance;
            _isLoggedIn = await authHandler.Authenticate(_client);
            if (_isLoggedIn)
            {
                if (await IsValidBvsOrTestSet() && await Start())
                {
                    _isPolling = true;
                    if (await _pollHandler.Poll())
                    {
                        var publisher = new LabPublisher(_client, _args.EntityId, _runHandler.RunId, _runHandler.NameSuffix);
                        res = await publisher.Publish(_args.ServerUrl, _args.Domain, _args.Project);
                    }
                    _isPolling = false;
                }
                await authHandler.Logout(_client);
                _isLoggedIn = false;
            }
            _isRunning = false;

            return res;
        }
Exemplo n.º 3
0
        private static void Main(string[] args)
        {
            try
            {
                AppUtility.ParseArgs(args);
                TestResultBuilder builder    = new TestResultBuilder();
                TestSuites        testSuites = builder.Build(new TestResultBuilderArgument
                {
                    TestCases = new CheckModReportFileParser().ParseFile(ApplicationData.ModCheckReportFilePath,
                                                                         ApplicationData.TestMode),
                    TestSuiteName = "Mod::Check()"
                });
                TestSuiteWriter writer   = new TestSuiteWriter();
                string          testName = "TEST-" + DateTime.Now.ToString("yyyy-MM-dd-HHmmss") + ".xml";
                writer.WriteToFile(testSuites, Path.Combine(ApplicationData.EaWUnitReportOutputPath, testName));
            }
            catch (Exception e)
            {
                Console.Error.WriteLine($"An error occured {e}", e.Message);
                ApplicationData.ExitCode = 1;
                AppUtility.PrintUsage();
            }

            Environment.Exit(ApplicationData.ExitCode);
        }
Exemplo n.º 4
0
        internal TestSuites Build(TestResultBuilderArgument args)
        {
            if (args.TestCases.Any())
            {
                ApplicationData.ExitCode = 1;
            }

            TestSuites testSuites = new TestSuites
            {
                Disabled  = "0",
                Errors    = "0",
                Failures  = args.TestCases.Count.ToString(),
                Name      = args.TestSuiteName,
                TestSuite = new List <TestSuite>()
            };

            TestSuite testSuite = new TestSuite
            {
                Name     = args.TestSuiteName,
                Id       = "0",
                Tests    = args.TestCases.Count.ToString(),
                Failures = args.TestCases.Count.ToString(),
                TestCase = args.TestCases
            };

            testSuites.TestSuite.Add(testSuite);
            return(testSuites);
        }
Exemplo n.º 5
0
        public void failure_messages_are_deserialized()
        {
            TestSuites suites =
                XmlParser.Get(@"<testsuites>
          <testsuite name=""uspBillOfMaterials"" tests=""1"" errors=""0"" failures=""1"">            
            <testcase classname=""uspBillOfMaterials"" name=""test does not return level 2 components of a level 0 assembly"">
              <failure message=""TODO:Implement this test."" />
            </testcase>
          </testsuite>
        </testsuites>");

            TestSuite testSuite = suites.Suites.FirstOrDefault(p => p.Name == "uspBillOfMaterials");

            Assert.IsNotNull(testSuite, "Unable to deseialize test suite");

            Test testResult =
                testSuite
                .Tests.FirstOrDefault(
                    p =>
                    p.ClassName == "uspBillOfMaterials" &&
                    p.Name == "test does not return level 2 components of a level 0 assembly");


            Assert.AreEqual("TODO:Implement this test.", testResult.Failure.Message);
        }
Exemplo n.º 6
0
        internal void LoadFromSettings(Settings settings)
        {
            if (string.IsNullOrEmpty(settings.TfsUrl) || string.IsNullOrEmpty(settings.ProjectName))
            {
                return;
            }
            var tfs = new TfsTeamProjectCollection(new Uri(settings.TfsUrl));

            SelectedProject = tfs.GetService <ITestManagementService>().GetTeamProject(settings.ProjectName);

            while (_pendingTasks.Count > 0)
            {
                Application.DoEvents();
            }

            if (string.IsNullOrEmpty(settings.TestPlan))
            {
                return;
            }

            SelectedTestPlan = TestPlans.SingleOrDefault(i => i.Name == settings.TestPlan);

            while (_pendingTasks.Count > 0)
            {
                Application.DoEvents();
            }

            if (string.IsNullOrEmpty(settings.TestSuite))
            {
                return;
            }

            SelectedTestSuite = TestSuites.SingleOrDefault(i => i.Title == settings.TestSuite);
            ExportFileName    = settings.ExportFilename;
        }
Exemplo n.º 7
0
        internal void WriteToFile(TestSuites testSuites, string filePath)
        {
            XmlSerializer ser    = new XmlSerializer(typeof(TestSuites));
            TextWriter    writer = new StreamWriter(filePath);

            ser.Serialize(writer, testSuites);
            writer.Close();
        }
Exemplo n.º 8
0
        private TestSuites CreateTestSuites(IDictionary <string, TestSuite> testSets)
        {
            TestSuites       res        = new TestSuites();
            List <TestSuite> testsuites = res.ListOfTestSuites;

            testSets.Values.ForEach(ts => testsuites.Add(ts));
            return(res);
        }
 public void WriteTestSuiteListToStream(TestSuites testSuiteList, StreamWriter sw)
 {
     //sw.WriteLine("<testsuites>");
     foreach (TestSuite suite in testSuiteList.Suites)
     {
         WriteTestSuiteToStream(suite, sw);
     }
     //sw.WriteLine("</testsuites>");
 }
Exemplo n.º 10
0
        public void failure_is_reported_when_no_tests_run()
        {
            TestSuites suites =
                XmlParser.Get(@"<testsuites>
                                      <testsuite name=""uspBillOfMaterials"" tests=""0"" errors=""0"" failures=""0"">                        
                                      </testsuite>
                                    </testsuites>");

            Assert.IsFalse(suites.Passed());
        }
Exemplo n.º 11
0
        /// <summary>
        ///
        /// </summary>
        /// <param name=""></param>
        /// <returns></returns>
        public static bool SetWebDriver(TestSuites category)
        {
            if (webDriver != null)
            {
                if (category == webDriverCategory)
                {
                    return(true);
                }
                else
                {
                    KillWebDriver();
                }
            }

            webDriverCategory = category;
            Test.Log.Message("Starting Selenium WebDriver for " + WebDriverName);

            switch (webDriverCategory)
            {
            case TestSuites.CHROME:
                LoadChromeDriver(0);
                break;

            case TestSuites.EDGE:
                LoadEdgeDriver(0);
                break;

            case TestSuites.FIREFOX:
                LoadFirefoxDriver(0);
                break;

            case TestSuites.INTERNETEXPLORER:
                LoadIEDriver(0);
                break;

            case TestSuites.PHANTOMJS:
                LoadPhantomJSDriver(0);
                break;

            case TestSuites.SAFARI:
                LoadSafariDriver(0);
                break;

            default:
                Test.Log.Message("Tests needing Selenium for " + WebDriverName + " are not supported at this time. Test Programmers must add support.",
                                 LoggingLevel.Critical, Test.Log.StopSignIcon);
                return(false);
            }

            webDriver.Manage().Window.Maximize();
            Test.Log.DebugLevelOnly("Window size = " + webDriver.Manage().Window.Size, (int)Test.GLL);
            Test.Log.DebugLevelOnly("Window position = " + webDriver.Manage().Window.Position, (int)Test.GLL);
            return(true);
        }
        private async Task <bool> Run(string resFilename, RunManager runMgr)
        {
            TestSuites testsuites = await runMgr.Execute();

            if (await SaveResults(resFilename, testsuites))
            {
                return(testsuites?.ListOfTestSuites.Any(ts => ts.ListOfTestCases.Any()) == true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 13
0
        public void success_is_reported_when_all_tests_pass()
        {
            TestSuites suites =
                XmlParser.Get(@"<testsuites>
          <testsuite name=""uspBillOfMaterials"" tests=""1"" errors=""0"" failures=""0"">            
            <testcase classname=""uspBillOfMaterials"" name=""test does not return level 2 components of a level 0 assembly"">              
            </testcase>
          </testsuite>
        </testsuites>");


            Assert.IsTrue(suites.Passed());
        }
Exemplo n.º 14
0
        public void failure_is_reported_when_a_test_fails()
        {
            TestSuites suites =
                XmlParser.Get(@"<testsuites>
          <testsuite name=""uspBillOfMaterials"" tests=""1"" errors=""0"" failures=""1"">            
            <testcase classname=""uspBillOfMaterials"" name=""test does not return level 2 components of a level 0 assembly"">
              <failure message=""TODO:Implement this test."" />
            </testcase>
          </testsuite>
        </testsuites>");


            Assert.IsFalse(suites.Passed());
        }
        /// <summary>
        /// Convert the ContentInformaiton struct defined in adapter to stack
        /// </summary>
        /// <param name="contentInfo">The contentInformation  defined in pccrc</param>
        /// <returns>Return the ContentInformaiton type defined in stack</returns>
        public static TestTools.StackSdk.BranchCache.Pccrc.Content_Information_Data_Structure ConvertTostackForContentInfo(
            TestSuites.Pchc.SegmentInformation contentInfo)
        {
            TestTools.StackSdk.BranchCache.Pccrc.Content_Information_Data_Structure contentInfoStack;
            contentInfoStack.dwHashAlgo = ConvertToStackFordwHash(contentInfo.DwHashAlgo);
            contentInfoStack.dwOffsetInFirstSegment = contentInfo.DwOffsetInFirstSegment;
            contentInfoStack.dwReadBytesInLastSegment = contentInfo.DwReadBytesInLastSegment;
            contentInfoStack.Version = contentInfo.Version;
            contentInfoStack.cSegments = contentInfo.CSegments;
            contentInfoStack.blocks = ConvertToStackForSegBlocks(contentInfo.Blocks);
            contentInfoStack.segments = ConvertToStackForSegDescription(contentInfo.Segments);

            return contentInfoStack;
        }
Exemplo n.º 16
0
        public async Task <TestSuites> Publish(string url, string domain, string project)
        {
            TestSuites testSuites         = null;
            GetRequest testSetRunsRequest = GetRunEntityTestSetRunsRequest(_client, _runId);
            Response   response           = await testSetRunsRequest.Execute();

            var    testInstanceRun = GetTestInstanceRun(response);
            string entityName      = await GetEntityName();

            if (testInstanceRun?.Any() == true)
            {
                testSuites = new JUnitParser(_entityId).ToModel(testInstanceRun, entityName, url, domain, project);
            }

            return(testSuites);
        }
Exemplo n.º 17
0
        public void failure_count_is_correct_across_testsuites()
        {
            TestSuites suites =
                XmlParser.Get(@"<testsuites>
          <testsuite name=""uspBillOfMaterials"" tests=""1"" errors=""0"" failures=""1"">            
            <testcase classname=""uspBillOfMaterials"" name=""test does not return level 2 components of a level 0 assembly"">              
                <failure message=""Ouch"" />
            </testcase>
          </testsuite>
          <testsuite name=""cookingTests"" tests=""1"" errors=""0"" failures=""99"">            
            <testcase classname=""uspBillOfMaterials"" name=""test does not return level 2 components of a level 0 assembly"">              
                <failure message=""Ouch Again"" />            
            </testcase>
          </testsuite>
        </testsuites>");

            Assert.AreEqual(100, suites.FailureCount());
        }
        private async Task <bool> SaveResults(string filePath, TestSuites testsuites)
        {
            if (testsuites != null)
            {
                string xml;
                try
                {
                    xml = testsuites.ToXML();
                }
                catch (ThreadInterruptedException)
                {
                    throw;
                }
                catch (Exception e)
                {
                    LogError(e, ErrorCategory.ParserError);
                    return(false);
                }
                try
                {
                    using StreamWriter file = new StreamWriter(filePath, true);
                    await file.WriteAsync(xml);

                    return(true);
                }
                catch (ThreadInterruptedException)
                {
                    throw;
                }
                catch (Exception e)
                {
                    LogError(e, ErrorCategory.WriteError);
                }
            }
            return(false);
        }
Exemplo n.º 19
0
        public string[] GetUnattachedTestSuites()
        {
            var dir = Path.GetDirectoryName(SolutinFilePath);

            return(Directory.GetDirectories(dir ?? "").Select(Path.GetFileName).Except(TestSuites.Select(s => s.Name)).ToArray());
        }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="category">The TestSuite value for this test</param>
 /// <returns></returns>
 public SeleniumTest(TestSuites category)
 {
     webDriverCategory = category;
 }
 public VerifySearchResults(TestSuites category) : base(category)
 {
 }
Exemplo n.º 22
0
 public void Add(TestSuite suite)
 {
     TestSuites.Add(suite);
 }