示例#1
0
        public void RunTests()
        {
            // Create test runner
            var testRunner = new SimpleTestRunner();

            // Load this assembly to test runner
            var assemblies = new List<string>();
            assemblies.Add(GetType().Assembly.Location);

            var testPackage = new TestPackage(GetType().FullName, assemblies);

            bool loaded = testRunner.Load(testPackage);
            if (!loaded)
                throw new InvalidOperationException("Can't load this assembly into test package");

            // Run all tests in this assembly
            testRunner.BeginRun(this, this);
            testRunner.Wait();

            // Summarize
            TestResult testResult = testRunner.EndRun();
            Console.WriteLine("testResult={0}", testResult);
        }