generated from dailydevops/template-dotnet
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathContinuousTestBase.cs
More file actions
42 lines (36 loc) · 1.2 KB
/
ContinuousTestBase.cs
File metadata and controls
42 lines (36 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
namespace NetEvolve.Extensions.NUnit;
using System.Threading.Tasks;
using global::NUnit.Framework;
using global::NUnit.Framework.Interfaces;
/// <summary>
/// Basic implementation for the execution of continuous tests, based on <see cref="OrderAttribute"/>.
/// If a test fails, all subsequent tests are disabled.
/// </summary>
public abstract class ContinuousTestBase
{
private bool _stopExecution;
/// <summary>
/// Setup method, that checks whether the triggered test should be executed or cancelled.
/// </summary>
[SetUp]
public virtual Task SetUpAsync()
{
if (_stopExecution)
{
Assert.Inconclusive("Previous test failed, further execution for this test class has been disabled!");
}
return Task.CompletedTask;
}
/// <summary>
/// Tear-down method, which determines whether the previous test was faulty. If <see langword="true"/>, the following tests are disabled.
/// </summary>
[TearDown]
public virtual Task TearDownAsync()
{
if (TestContext.CurrentContext.Result.Outcome.Status == TestStatus.Failed)
{
_stopExecution = true;
}
return Task.CompletedTask;
}
}