Ejemplo n.º 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>());
        }
Ejemplo n.º 2
0
        public void AreValidSourcesShouldReturnFalseIfValidSourceExtensionsIsEmpty()
        {
            this.testablePlatformServiceProvider.MockTestSourceValidator.SetupGet(ts => ts.ValidSourceExtensions).Returns(new List <string> {
            });
            MSTestDiscoverer discoverer = new MSTestDiscoverer();

            Assert.IsFalse(discoverer.AreValidSources(new List <string> {
                "dummy.te"
            }));
        }
Ejemplo n.º 3
0
        public void AreValidSourcesShouldThrowIfPlatformsValidSourceExtensionsIsNull()
        {
            this.testablePlatformServiceProvider.MockTestSourceValidator.SetupGet(ts => ts.ValidSourceExtensions).Returns((List <string>)null);
            MSTestDiscoverer discoverer = new MSTestDiscoverer();

            Action a = () => discoverer.AreValidSources(new List <string> {
                "dummy"
            });

            ActionUtility.ActionShouldThrowExceptionOfType(a, typeof(ArgumentNullException));
        }
Ejemplo n.º 4
0
        public async Task <List <TestCase> > LoadTests(string folder)
        {
            var task = Task.Run(() =>
            {
                ITestDiscoverer discoverer = new MSTestDiscoverer();
                var sources  = GetSources(folder, discoverer);
                var fakeSink = new FakeTestCaseDiscoverySink();
                discoverer.DiscoverTests(sources, new FakeContext(), new FakeLogger(), fakeSink);
                return(fakeSink.testCases);
            });

            return(await task);
        }
Ejemplo n.º 5
0
        public void TestInit()
        {
            this.testablePlatformServiceProvider = new TestablePlatformServiceProvider();

            this.mockMessageLogger         = new Mock <IMessageLogger>();
            this.mockTestCaseDiscoverySink = new Mock <ITestCaseDiscoverySink>();
            this.mockDiscoveryContext      = new Mock <IDiscoveryContext>();
            this.mockRunSettings           = new Mock <IRunSettings>();
            this.discoverer = new MSTestDiscoverer();

            this.testablePlatformServiceProvider = new TestablePlatformServiceProvider();
            PlatformServiceProvider.Instance     = this.testablePlatformServiceProvider;
        }
        private IEnumerable <TestCase> GetTests(string source)
        {
            var pluginPath = Path.GetDirectoryName(GetType().Assembly.Location);
            var sourcePath = Path.GetDirectoryName(source);
            var paths      = new[] { pluginPath, sourcePath };

            using (new AssemblyResolver(paths))
            {
                var sink       = new DiscoverySink();
                var discoverer = new MSTestDiscoverer();
                discoverer.DiscoverTests(source.ToEnumerable(), null, new NullLogger(), sink);
                return(sink.TestCases);
            }
        }