Ejemplo 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;
 }
Ejemplo n.º 2
0
 private TestSourceSettings AddSource(TestSourceSettings source)
 {
     if (source != null)
     {
         RemoveSource(source.Source);
         Sources.Add(source);
     }
     return source;
 }
 private void DeleteSettingsFile(TestSourceSettings sourceSettings)
 {
     try
     {
         File.Delete(SettingsFilePath(sourceSettings.Source));
     }
     catch
     {
         // Do nothing
     }
 }
Ejemplo n.º 4
0
 protected virtual TestCase CreateTestCase(TestSourceSettings settings, Spec spec)
 {
     var testCase = new TestCase(spec.FullyQualifiedName, TestAdapterInfo.ExecutorUri, settings.Source);
     testCase.DisplayName = spec.DisplayName;
     if (spec.Traits != null)
     {
         foreach (var trait in spec.Traits)
         {
             if (!string.IsNullOrWhiteSpace(trait.Name))
             {
                 testCase.Traits.Add(trait.Name, trait.Value);
             }
         }
     }
     if (spec.Source != null)
     {
         testCase.CodeFilePath = spec.Source.FileName;
         if (spec.Source.LineNumber.HasValue)
         {
             testCase.LineNumber = spec.Source.LineNumber.Value;
         }
     }
     return testCase;
 }
Ejemplo n.º 5
0
        private void RunTest(TestSourceSettings settings, ITestLogger logger, IRunContext runContext, IFrameworkHandle frameworkHandle, Spec spec)
        {
            var testCase = CreateTestCase(settings, spec);
            var outcome = TestOutcome.None;

            frameworkHandle.RecordStart(testCase);
            foreach (var result in spec.Results)
            {
                if (result.Skipped && outcome != TestOutcome.Failed)
                {
                    outcome = TestOutcome.Skipped;
                }

                if (result.Success && outcome == TestOutcome.None)
                {
                    outcome = TestOutcome.Passed;
                }

                if (!result.Success && !result.Skipped)
                {
                    outcome = TestOutcome.Failed;
                }

                frameworkHandle.RecordResult(GetResult(testCase, result, frameworkHandle));
            }
            frameworkHandle.RecordEnd(testCase, outcome);
        }
Ejemplo n.º 6
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;
 }
 private void Save(TestSourceSettings sourceSettings)
 {
     var saved = false;
     var i = 0;
     while (!saved)
     {
         try
         {
             using (var writer = XmlWriter.Create(SettingsFilePath(sourceSettings.Source)))
             {
                 _serializer.Serialize(writer, sourceSettings, _serializerNamespaces);
             }
             saved = true;
         }
         catch (Exception)
         {
             i += 1;
             if (i >= 10)
             {
                 throw;
             }
             Thread.Sleep(100);
         }
     }
 }
 public static void Save(string settingsFileDirectory, TestSourceSettings sourceSettings)
 {
     new SourceSettingsPersister(settingsFileDirectory).Save(sourceSettings);
 }