CreateTestCases() public méthode

public CreateTestCases ( ) : IList
Résultat IList
        public void CreateTestCases_AdditionalTestDiscoveryParam_TestDiscoveryUsesAdditionalTestDiscoveryParams()
        {
            MockOptions.Setup(o => o.AdditionalTestDiscoveryParam).Returns("-testDiscoveryFlag");
            MockOptions.Setup(o => o.ParseSymbolInformation).Returns(false);

            var reportedTestCases = new List <TestCase>();
            var factory           = new TestCaseFactory(TestResources.TestDiscoveryParamExe, MockLogger.Object, TestEnvironment.Options, null);
            var returnedTestCases = factory.CreateTestCases(testCase => reportedTestCases.Add(testCase));

            reportedTestCases.Count.Should().Be(2);
            reportedTestCases.Should().Contain(t => t.FullyQualifiedName == "TestDiscovery.TestFails");
            reportedTestCases.Should().Contain(t => t.FullyQualifiedName == "TestDiscovery.TestPasses");
        }
        public IList<TestCase> GetTestsFromExecutable(string executable)
        {
            var factory = new TestCaseFactory(executable, _testEnvironment, _diaResolverFactory);
            IList<TestCase> testCases = factory.CreateTestCases();

            _testEnvironment.LogInfo("Found " + testCases.Count + " tests in executable " + executable);
            foreach (TestCase testCase in testCases)
            {
                _testEnvironment.DebugInfo("Added testcase " + testCase.DisplayName);
            }

            return testCases;
        }
Exemple #3
0
        public void CreateTestCases_DiscoveryTimeoutIsExceeded_DiscoveryIsCanceledAndCancelationIsLogged()
        {
            MockOptions.Setup(o => o.TestDiscoveryTimeoutInSeconds).Returns(1);
            MockOptions.Setup(o => o.ParseSymbolInformation).Returns(false);

            var reportedTestCases = new List <TestCase>();
            var stopWatch         = Stopwatch.StartNew();
            var factory           = new TestCaseFactory(TestResources.TenSecondsWaiter, MockLogger.Object, TestEnvironment.Options, null);
            var returnedTestCases = factory.CreateTestCases(testCase => reportedTestCases.Add(testCase));

            stopWatch.Stop();

            reportedTestCases.Should().BeEmpty();
            returnedTestCases.Should().BeEmpty();
            stopWatch.Elapsed.Should().BeGreaterOrEqualTo(TimeSpan.FromSeconds(1));
            stopWatch.Elapsed.Should().BeLessThan(TimeSpan.FromSeconds(2));
            MockLogger.Verify(o => o.LogError(It.Is <string>(s => s.Contains(TestResources.TenSecondsWaiter))), Times.Once);
            MockLogger.Verify(o => o.DebugError(It.Is <string>(s => s.Contains(Path.GetFileName(TestResources.TenSecondsWaiter)))), Times.Once);
        }
Exemple #4
0
        private void CheckIfSourceLocationsAreFound()
        {
            string executable = TestResources.LoadTests_ReleaseX86;

            executable.AsFileInfo().Should().Exist();
            string pdb = Path.ChangeExtension(executable, ".pdb");

            pdb.AsFileInfo().Should().Exist();
            string renamedPdb = $"{pdb}.bak";

            renamedPdb.AsFileInfo().Should().NotExist();

            try
            {
                File.Move(pdb, renamedPdb);
                pdb.AsFileInfo().Should().NotExist();

                var reportedTestCases  = new List <TestCase>();
                var diaResolverFactory = new DefaultDiaResolverFactory();
                var factory            = new TestCaseFactory(executable, MockLogger.Object, TestEnvironment.Options, diaResolverFactory);
                var returnedTestCases  = factory.CreateTestCases(testCase => reportedTestCases.Add(testCase));

                returnedTestCases.Should().OnlyContain(tc => !HasSourceLocation(tc));
                reportedTestCases.Should().OnlyContain(tc => !HasSourceLocation(tc));

                reportedTestCases.Clear();
                MockOptions.Setup(o => o.AdditionalPdbs).Returns("$(ExecutableDir)\\*.pdb.bak");
                MockOptions.Setup(o => o.TestDiscoveryTimeoutInSeconds).Returns(10000);
                factory           = new TestCaseFactory(executable, MockLogger.Object, TestEnvironment.Options, diaResolverFactory);
                returnedTestCases = factory.CreateTestCases(testCase => reportedTestCases.Add(testCase));

                reportedTestCases.Should().OnlyContain(tc => HasSourceLocation(tc));
                returnedTestCases.Should().OnlyContain(tc => HasSourceLocation(tc));
            }
            finally
            {
                File.Move(renamedPdb, pdb);
                pdb.AsFileInfo().Should().Exist();
            }
        }