Beispiel #1
0
 private static void FailIgnoredTests(Dictionary <ITest, string> dict, ITest suite)
 {
     lock (Locker)
     {
         foreach (var pair in dict)
         {
             pair.Key.Properties.Set(AllureConstants.TestIgnoreReason,
                                     $"Test was ignored by reason: {pair.Value}");
             var testResult = new TestContext.ResultAdapter(new TestCaseResult(new TestMethod(pair.Key.Method)));
             AddInfoToIgnoredTest(ref testResult);
             pair.Key.Properties.Set(AllureConstants.TestResult, testResult);
             AllureLifecycle.Instance.Storage.ClearStepContext();
             AllureLifecycle.Instance.Storage.CurrentThreadStepContext.AddLast(pair.Key.Properties
                                                                               .Get(AllureConstants.TestUuid).ToString());
             AllureLifecycle.Instance.StartStepAndStopIt(null, $"Test was ignored by reason: {pair.Value}",
                                                         Status.skipped);
             AllureLifecycle.Instance.UpdateTestContainer(
                 pair.Key.Properties.Get(AllureConstants.TestContainerUuid).ToString(),
                 x => x.start = AllureLifecycle.ToUnixTimestamp());
             AllureLifecycle.Instance.UpdateTestCase(pair.Key.Properties
                                                     .Get(AllureConstants.TestUuid).ToString(),
                                                     x =>
             {
                 x.start = AllureLifecycle.ToUnixTimestamp();
                 x.labels.RemoveAll(q => q.name == "thread");
                 x.labels.Add(Label.Thread());
                 var subSuites = x.labels.Where(lbl => lbl.name.ToLower().Equals("subsuite")).ToList();
                 subSuites.ForEach(lbl => x.labels.Remove(lbl));
                 x.labels.Add(Label.SubSuite("Ignored tests/test-cases"));
             });
             Thread.Sleep(5);
             StopAllureLogging(testResult, pair.Key.Properties
                               .Get(AllureConstants.TestUuid).ToString(), pair.Key.Properties
                               .Get(AllureConstants.TestContainerUuid).ToString(), suite, true, pair.Value);
         }
     }
 }