示例#1
0
        public void Run_Passes_Along_NUnitEngineException()
        {
            _driver.Run(Arg.Any <ITestEventListener>(), Arg.Any <string>()).Throws(new NUnitEngineException("Message"));
            var ex = Assert.Throws <NUnitEngineException>(() => _directTestRunner.Run(Substitute.For <ITestEventListener>(), _testFilter));

            Assert.That(ex.Message, Is.EqualTo("Message"));
        }
示例#2
0
        public void Run(string filePath, string expectedType)
        {
            IFrameworkDriver driver = GetDriver(filePath);
            var result = XmlHelper.CreateXmlNode(driver.Run(new NullListener(), TestFilter.Empty.Text));

            Assert.That(result.Name, Is.EqualTo("test-suite"));
            Assert.That(result.GetAttribute("id"), Is.EqualTo(EXPECTED_ID));
            Assert.That(result.GetAttribute("name"), Is.EqualTo(filePath));
            Assert.That(result.GetAttribute("fullname"), Is.EqualTo(Path.GetFullPath(filePath)));
            Assert.That(result.GetAttribute("type"), Is.EqualTo(expectedType));
            Assert.That(result.GetAttribute("runstate"), Is.EqualTo(_expectedRunState));
            Assert.That(result.GetAttribute("testcasecount"), Is.EqualTo("0"));
            Assert.That(GetSkipReason(result), Is.EqualTo(_expectedReason));
            Assert.That(result.SelectNodes("test-suite").Count, Is.EqualTo(0), "Load result should not have child tests");
            Assert.That(result.GetAttribute("result"), Is.EqualTo(_expectedResult));
            Assert.That(result.GetAttribute("label"), Is.EqualTo(_expectedLabel));
            Assert.That(result.SelectSingleNode("reason/message").InnerText, Is.EqualTo(_expectedReason));
        }
示例#3
0
        /// <summary>
        /// Run the tests in the loaded TestPackage.
        /// </summary>
        /// <param name="listener">An ITestEventHandler to receive events</param>
        /// <param name="filter">A TestFilter used to select tests</param>
        /// <returns>
        /// A TestEngineResult giving the result of the test execution
        /// </returns>
        protected override TestEngineResult RunTests(ITestEventListener listener, TestFilter filter)
        {
            EnsurePackageIsLoaded();

            string driverResult;

            try
            {
                driverResult = _driver.Run(listener, filter.Text);
            }
            catch (Exception ex) when(!(ex is NUnitEngineException))
            {
                throw new NUnitEngineException("An exception occurred in the driver while running tests.", ex);
            }

            if (_assemblyResolver != null)
            {
                _assemblyResolver.RemovePathFromFile(TestPackage.FullName);
            }

            return(new TestEngineResult(driverResult));
        }