예제 #1
0
        public void ShouldReturnFailureIfCantFindPesterModule()
        {
            _runContext.Setup(m => m.TestRunDirectory).Returns(TestContext.TestDeploymentDir);
            _runContext.Setup(m => m.SolutionDirectory).Returns(GetModuleDir("1.0.0"));

            var testCase = WriteTestFile("Pester||Test||Blah||Should pass", String.Empty);
            var result   = _executor.RunTest(_powerShell, testCase, _runContext.Object);

            Assert.AreEqual(TestOutcome.Failed, result.Outcome);
            Assert.IsTrue(result.ErrorMessage.Contains("Failed to load Pester module."));
        }
        public void ShouldReturnSuccessfulTestResults()
        {
            const string testScript = @"
            Describe 'Test' {
                Context 'Blah' {
                     It 'Should pass' {
                         1 | Should be 1
                     }
                }
            }
            ";

            _runContext.Setup(m => m.TestRunDirectory).Returns(TestContext.TestDeploymentDir);
            _runContext.Setup(m => m.SolutionDirectory).Returns(TestContext.TestDeploymentDir);

            var testCase = WriteTestFile("Pester||Test||Blah||Should pass", testScript);
            var result   = _executor.RunTest(_powerShell, testCase, _runContext.Object);

            Assert.AreEqual(TestOutcome.Passed, result.Outcome);
        }