Beispiel #1
0
        static void Main(string[] args)
        {
            AppDomain.CurrentDomain.AssemblyResolve += ResolveDependentAssembly;

            // LoadFrom(@"C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\Extensions\TestPlatform");
            // LoadFrom(@"C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\CommonExtensions\Microsoft\TestWindow\Team Explorer");
            // LoadFrom(@"D:\Visual Studio 2015\Projects\BrowserTestAdapter\ConsoleApp1\bin\Debug\ForTest", SearchOption.TopDirectoryOnly);
            //LoadFrom(Environment.CurrentDirectory, SearchOption.AllDirectories);
            // test();
            //    AppDomain.CurrentDomain.AssemblyResolve += ResolveDependentAssembly;
            var ass      = Assembly.LoadFrom(@"D:\Visual Studio 2015\Projects\BrowserTestAdapter\ConsoleApp1\bin\Debug\Microsoft.VisualStudio.TestPlatform.Extensions.TrxLogger.dll");
            var type     = ass.GetType("Microsoft.VisualStudio.TestPlatform.Extensions.TrxLogger.TrxLogger");
            var instance = Activator.CreateInstance(type);
            var method   = type.GetMethods().Where(m => m.Name == "Initialize").First();

            var ev = new MyEvents();

            method.Invoke(instance, new object[] { ev, @"D:\Visual Studio 2015\Projects\BrowserTestAdapter\ConsoleApp1\bin\Debug\Results" });

            ITestDiscoverer discoverer = new MSTestDiscoverer();
            string          folder     = @"D:\Visual Studio 2015\Projects\BrowserTestAdapter\Tests\bin\Debug";
            var             sources    = Directory.EnumerateFiles(folder).Where(file => Path.GetExtension(file) == ".dll").ToList();

            Environment.CurrentDirectory = @"D:\Visual Studio 2015\Projects\BrowserTestAdapter\ConsoleApp1\bin\Debug\ForTest";
            var fakeSink = new FakeTestCaseDiscoverySink();

            discoverer.DiscoverTests(sources, new FakeContext(), new FakeLogger(), fakeSink);
            Console.WriteLine("TEST CASES = " + fakeSink.testCases.Count);
            ITestExecutor executor = new MSTestExecutor();

            executor.RunTests(fakeSink.testCases, new FakeRunContext(), new FakeFrameworkHandle(ev));
            // ev.SendTestRunComplete(new List<AttachmentSet>());
        }
Beispiel #2
0
 public FakeFrameworkHandle(MyEvents e)
 {
     this.myEvents = e;
 }