Exemplo n.º 1
0
 private async Task<int> DiscoverTests(TestSourceSettings settings, ITestLogger logger, ITestCaseDiscoverySink discoverySink)
 {
     logger = new TestLogger(logger, settings.Name, "Discover");
     var count = 0;
     var tests = new ConcurrentBag<Guid>();
     if (settings.Port > 0)
     {
         logger.Debug("Start");
         var discoverCommand = new DiscoverCommand(settings.Port);
         await discoverCommand.Run(spec =>
         {
             var testCase = CreateTestCase(settings, spec);
             tests.Add(testCase.Id);
             discoverySink.SendTestCase(testCase);
             count += 1;
         });
         await new RequestRunCommand(settings.Port).Run(tests);
         logger.Debug("Complete: {0} tests", count);
     }
     else
     {
         logger.Error("Not connected to {0}", TestAdapterInfo.Name);
     }
     return count;
 }
Exemplo n.º 2
0
 public async Task PopulateKarmaSpecs()
 {
     if (IsValid && _karmaSpecs == null)
     {
         Globals.IsTest = true;
         var karmaSpecs = new List<Spec>();
         var settings = new KarmaSettings(Name, KarmaConfig, f => File.Exists(f), BaseDirectory, Logger);
         if (settings.AreValid)
         {
             try
             {
                 var server = new KarmaServer(settings, Logger);
                 server.OutputReceived += line => _karmaOutput.Add(line);
                 server.ErrorReceived += line => _karmaOutput.Add(line);
                 var port = await server.StartServer(60000);
                 var stopCommand = new StopCommand(port);
                 var discoverCommand = new DiscoverCommand(port);
                 await discoverCommand.Run(spec => karmaSpecs.Add(spec));
                 await stopCommand.Run();
                 await server.Finished;
                 _karmaSpecs = karmaSpecs;
                 Logger.Info("{0} specs discovered", _karmaSpecs.Count());
             }
             catch (AggregateException ex)
             {
                 _validator.Validate(false, ex.InnerExceptions.First().Message);
             }
             catch (Exception ex)
             {
                 _validator.Validate(false, ex.Message);
             }
         }
         else
         {
             _validator.Validate(false, settings.InvalidReason);
         }
     }
 }
Exemplo n.º 3
0
 private async Task<int> RunTests(TestSourceSettings settings, ITestLogger logger, IRunContext runContext, IFrameworkHandle frameworkHandle)
 {
     logger = new TestLogger(logger, settings.Name, "Run");
     var count = 0;
     if (settings.Port > 0)
     {
         logger.Debug("Start");
         var discoverCommand = new DiscoverCommand(settings.Port);
         await discoverCommand.Run(spec =>
         {
             RunTest(settings, logger, runContext, frameworkHandle, spec);
             count += 1;
         });
         logger.Debug("Complete: {0} tests", count);
     }
     else
     {
         logger.Error("Not connected to {0}", TestAdapterInfo.Name);
     }
     return count;
 }