示例#1
0
        private static void RunInAppDomain(IFrameworkHandle frameworkHandle, IGrouping <string, TestCase> source, List <TestCase> tests)
        {
            var dir = Path.GetDirectoryName(source.Key);
            var cmd = new RunTests
            {
                AssemblyName = Path.GetFileName(source.Key), AssemblyPath = dir, Source = source.Key,
            };
            var dto = new List <TestCaseToRun>();

            foreach (TestCase testCase in tests)
            {
                var parts = testCase.FullyQualifiedName.Split('.');
                dto.Add(new TestCaseToRun(testCase.FullyQualifiedName)
                {
                    TestClassName  = parts[parts.Length - 2],
                    TestMethodName = parts[parts.Length - 1]
                });
            }

            using (var appDomainRunner = new AppDomainRunner(source.Key))
            {
                appDomainRunner.AddDirectory(dir);
                appDomainRunner.Create();


                var resultProxy = new TestResultProxy(frameworkHandle, tests);
                appDomainRunner.RunTests(cmd, resultProxy);
            }
        }
示例#2
0
        static async Task Main(string[] args)
        {
            var discoverer = new TestDiscoverer();

            discoverer.Load(new[] { typeof(IncidentWrapper).Assembly });
            var runner = new TestRunner(discoverer);

            runner.Load(new[] { typeof(IncidentWrapper).Assembly }).GetAwaiter().GetResult();
            var result = runner.RunAll().GetAwaiter().GetResult();
            var faulty = result.Where(x => !x.IsSuccess).ToList();

            var cmd = new RunTests
            {
                AssemblyName = typeof(EnvironmentTests).Assembly.GetName().Name,
                AssemblyPath = Path.GetDirectoryName(typeof(EnvironmentTests).Assembly.Location),
                //TestCases = new[]
                //{
                //    new TestCaseToRun("Coderr.IntegrationTests.Core.TestCases.EnvironmentTests.Clearing_environment_should_remove_all_incidents_in_it")
                //    {
                //        TestClassName = "EnvironmentTests",
                //        TestMethodName = "Clearing_environment_should_remove_all_incidents_in_it"
                //    },
                //},
                Source = typeof(EnvironmentTests).Assembly.Location
            };

            var receiver = new ConsoleReceiver();

            using (var coordinator = new AppDomainRunner("TesTSuite1"))
            {
                coordinator.Create();
                coordinator.AddDirectory(
                    @"C:\src\1tcompany\coderr\oss\Coderr.Server\src\Tools\Coderr.IntegrationTests\Coderr.IntegrationTests\bin\Debug\net461");
                coordinator.RunTests(cmd, receiver);
            }
        }