Example #1
0
        TDF.TestRunState run(TDF.ITestListener testListener, Assembly testAssembly, string where)
        {
            string      assemblyFile = new Uri(testAssembly.EscapedCodeBase).LocalPath;
            TestPackage package      = new TestPackage(assemblyFile);

            package.AddSetting("ProcessModel", "InProcess");
            package.AddSetting("DomainUsage", "None");

            ITestRunner runner = engine.GetRunner(package);

            var filterService          = engine.Services.GetService <ITestFilterService>();
            ITestFilterBuilder builder = filterService.GetTestFilterBuilder();

            if (!string.IsNullOrEmpty(where))
            {
                builder.SelectWhere(where);
            }

            var filter = builder.GetFilter();

            var testRunnerName = getTestRunnerName(testAssembly);
            var eventHandler   = new TestEventListener(testListener, testRunnerName);

            XmlNode result = runner.Run(eventHandler, filter);

            return(eventHandler.TestRunState);
        }
Example #2
0
        private TestFilter CreateTestFilter(string[] nameFilter)
        {
            ITestFilterBuilder builder = filterService.GetTestFilterBuilder();

            foreach (var testName in nameFilter)
            {
                builder.AddTest(testName);
            }
            return(builder.GetFilter());
        }
        public TestDriver(string path)
        {
            TestPackage        package        = new TestPackage(path);
            ITestEngine        engine         = TestEngineActivator.CreateInstance();
            var                _filterService = engine.Services.GetService <ITestFilterService>();
            ITestFilterBuilder builder        = _filterService.GetTestFilterBuilder();

            EmptyFilter = builder.GetFilter();
            TestRunner  = engine.GetRunner(package);
        }
Example #4
0
    static void Main(string[] args)
    {
        ITestEngine        engine         = TestEngineActivator.CreateInstance();
        ITestFilterService _filterService = engine.Services.GetService <ITestFilterService>();
        TestPackage        package        = new TestPackage(Assembly.GetExecutingAssembly().Location);

        package.AddSetting("WorkDirectory", Environment.CurrentDirectory);
        using (ITestRunner runner = engine.GetRunner(package))
        {
            ITestFilterBuilder builder = _filterService.GetTestFilterBuilder();
            XmlNode            result  = runner.Run(null, builder.GetFilter());
        }
    }
Example #5
0
        private TestFilter CreateTestFilter(ConsoleOptions options)
        {
            ITestFilterBuilder builder = _filterService.GetTestFilterBuilder();

            foreach (string testName in options.TestList)
            {
                builder.AddTest(testName);
            }

            if (options.WhereClauseSpecified)
            {
                builder.SelectWhere(options.WhereClause);
            }

            return(builder.GetFilter());
        }
        public TestFilter MakeTestFilter(IEnumerable <TestCase> testCases)
        {
            if (testCases.Count() == 0)
            {
                return(NoTestsFound);
            }

            ITestFilterBuilder filterBuilder = _filterService.GetTestFilterBuilder();

            foreach (TestCase testCase in testCases)
            {
                filterBuilder.AddTest(testCase.FullyQualifiedName);
            }

            return(filterBuilder.GetFilter());
        }
Example #7
0
        private TestFilter MakeTestFilter(IEnumerable <TestCase> testCases)
        {
            ITestFilterService filterService = TestEngine.Services.GetService <ITestFilterService>();

            if (filterService == null)
            {
                throw new NUnitEngineException("TestFilterService is not available. Engine in use is incorrect version.");
            }

            ITestFilterBuilder filterBuilder = filterService.GetTestFilterBuilder();

            foreach (TestCase testCase in testCases)
            {
                filterBuilder.AddTest(testCase.FullyQualifiedName);
            }

            return(filterBuilder.GetFilter());
        }
    static void Main(string[] args)
    {
        // set up the options
        string      path    = Assembly.GetExecutingAssembly().Location;
        TestPackage package = new TestPackage(path);

        package.AddSetting("WorkDirectory", Environment.CurrentDirectory);

        // prepare the engine
        ITestEngine        engine         = TestEngineActivator.CreateInstance();
        var                _filterService = engine.Services.GetService <ITestFilterService>();
        ITestFilterBuilder builder        = _filterService.GetTestFilterBuilder();
        TestFilter         emptyFilter    = builder.GetFilter();

        using (ITestRunner runner = engine.GetRunner(package))
        {
            // execute the tests
            XmlNode result = runner.Run(null, emptyFilter);
        }
    }
        protected void Page_Load(object sender, EventArgs e)
        {
            // set up the options
            string      path    = Assembly.GetExecutingAssembly().Location;
            TestPackage package = new TestPackage(path);

            package.AddSetting("ProcessModel", "Single");
            package.AddSetting("DomainUsage", "None");

            // prepare the engine
            ITestEngine        engine         = TestEngineActivator.CreateInstance();
            var                _filterService = engine.Services.GetService <ITestFilterService>();
            ITestFilterBuilder builder        = _filterService.GetTestFilterBuilder();
            TestFilter         emptyFilter    = builder.GetFilter();

            using (ITestRunner runner = engine.GetRunner(package))
            {
                // execute the tests
                XmlNode result = runner.Run(null, emptyFilter);
                lblTest.Text = result.InnerText;
            }
        }
Example #10
0
 public FilterBuilder(ITestFilterBuilder testFilterBuilder, bool runAssemblyByDefault = true)
 {
     _testFilterBuilder    = testFilterBuilder ?? throw new ArgumentNullException(nameof(testFilterBuilder));
     _runAssemblyByDefault = runAssemblyByDefault;
 }