C# Client Library
A C# Client Library for the AnalyzeRe REST API
Loading...
Searching...
No Matches
SkipUntil.cs
Go to the documentation of this file.
1using System;
2using System.Diagnostics;
3#if MSTEST
4using Microsoft.VisualStudio.TestTools.UnitTesting;
5#elif NUNIT
6using NUnit.Framework;
7#endif
8
10{
13 public static class Skip
14 {
17 public static readonly bool SKIPS_ENABLED = EnvironmentSettings.SKIPS_ENABLED;
18
23
29 public static void Until(DateTime skipExpiry, string targetRelease = null, string ticket = null)
30 {
31 if (!SKIPS_ENABLED) return;
32 string estRelease = skipExpiry.ToString(@"dd/MM/yyyy") +
33 (targetRelease == null ? "" : $" ({targetRelease})");
34 if (DateTime.UtcNow < skipExpiry)
35 {
36 string reason = $"Test skipped until {estRelease}.";
37 if (ticket != null)
38 reason += $" See {ticket}";
39 Debug.WriteLine(reason);
40 Assert.Inconclusive(reason);
41 }
42 else if (FAIL_ON_EXPIRED_SKIP)
43 {
44 string reason = $"Skip.Until expired on {estRelease}. " +
45 "Remove the skip or set a new estimated completion date " +
46 $"if {ticket ?? "the resolution"} has been postponed.";
47 Debug.WriteLine(reason);
48 Assert.Fail(reason);
49 }
50 }
51
54 public static void Indefinitely(string ticket = null)
55 {
56 if (!SKIPS_ENABLED) return;
57 string reason = "Test skipped indefinitely.";
58 if (ticket != null)
59 reason += $" See {ticket}";
60 Debug.WriteLine(reason);
61 Assert.Inconclusive(reason);
62 }
63
65 public static class UntilRelease
66 {
70 public static void Validation(string ticket = null) => Indefinitely($"Validation {ticket}");
71 }
72 }
73}
Retrieve settings from environment variables if they exist, or the project settings file otherwise.
static bool FAIL_ON_EXPIRED_SKIP
If true, expired SkipUntils will raise an exception saying they are expired. If false,...
static bool SKIPS_ENABLED
If true, SkipUntils can be used to skip tests. If false, SkipUntils will be ignored and all tests wil...
A helper class containing default skip dates.
Definition SkipUntil.cs:66
static void Validation(string ticket=null)
Skip a test due to a validation-related issue, possibly with no insight into when this issue is likel...
Class used in unit tests to mark tests as skipped by using Assert.Inconclusive() method.
Definition SkipUntil.cs:14
static readonly bool SKIPS_ENABLED
Whether skips are currently configured to be enabled. If disabled, calls to Skip tests do nothing,...
Definition SkipUntil.cs:17
static readonly bool FAIL_ON_EXPIRED_SKIP
Whether skips are configured to fail if they are past due. If true, an overdue skip will invokeAssert...
Definition SkipUntil.cs:22
static void Until(DateTime skipExpiry, string targetRelease=null, string ticket=null)
Skip the specified test until the specified date, after which this test should be treated as failing ...
Definition SkipUntil.cs:29
static void Indefinitely(string ticket=null)
Skip the specified test.
Definition SkipUntil.cs:54