Esempio n. 1
0
        public void RunTestSet(SMA.PowerShell powerShell, TestCaseSet testCaseSet, IRunContext runContext)
        {
            SetupExecutionPolicy();

            ImportPester(powerShell, runContext);

            FileInfo fileInfo = new FileInfo(testCaseSet.File);

            powerShell.AddCommand("Invoke-Pester")
            .AddParameter("Path", fileInfo.FullName)
            .AddParameter("TestName", testCaseSet.Describe)
            .AddParameter("PassThru");

            Collection <SMA.PSObject> psObjects = powerShell.Invoke();

            powerShell.Commands.Clear();

            Array testResults = GetTestResults(psObjects);

            testCaseSet.ProcessTestResults(testResults);
        }
Esempio n. 2
0
        private List <TestCaseSet> GetTestSets(IEnumerable <TestCase> tests)
        {
            List <TestCaseSet> list = new List <TestCaseSet>();

            //Enumerate over every It statement identified from the test files passed to the test adapter
            foreach (TestCase testCase in tests)
            {
                string      describe    = testCase.FullyQualifiedName.Split('.').First();
                string      codeFile    = testCase.CodeFilePath;
                TestCaseSet testCaseSet = list.FirstOrDefault(m => m.Describe.EqualsIgnoreCase(describe) && m.File.EqualsIgnoreCase(codeFile));

                //If this is the first time we've seen a test for a particular Describe, add that Describe to the test set list
                if (testCaseSet == null)
                {
                    testCaseSet = new TestCaseSet(codeFile, describe);
                    list.Add(testCaseSet);
                }

                testCaseSet.TestCases.Add(testCase);
            }

            return(list);
        }