-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NUnit - Add an ability to save OneTimeSetUp step results (#333)
* Move common steps * save onetime setup result * add random * skip adding empty onetimesetup result
- Loading branch information
1 parent
523118b
commit 2d62d65
Showing
6 changed files
with
161 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
using System.Threading.Tasks; | ||
using Allure.NUnit.Examples.CommonSteps; | ||
using NUnit.Allure.Attributes; | ||
using NUnit.Framework; | ||
|
||
namespace Allure.NUnit.Examples | ||
{ | ||
[AllureSuite("Tests - Async OneTime SetUp")] | ||
[Parallelizable(ParallelScope.All)] | ||
public class AllureAsyncOneTimeSetUpTests: BaseTest | ||
{ | ||
[OneTimeSetUp] | ||
public async Task OneTimeSetUp() | ||
{ | ||
await AsyncStepsExamples.PrepareDough(); | ||
await AsyncStepsExamples.CookPizza(); | ||
await AsyncStepsExamples.CookPizza(); | ||
await AsyncStepsExamples.CookPizza(); | ||
} | ||
|
||
[SetUp] | ||
public async Task SetUp() | ||
{ | ||
await AsyncStepsExamples.PrepareDough(); | ||
} | ||
|
||
[Test] | ||
[AllureName("Test1")] | ||
public async Task Test1() | ||
{ | ||
await AsyncStepsExamples.DeliverPizza(); | ||
await AsyncStepsExamples.Pay(); | ||
} | ||
|
||
[Test] | ||
[AllureName("Test2")] | ||
public async Task Test2() | ||
{ | ||
await AsyncStepsExamples.DeliverPizza(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
using NUnit.Allure.Attributes; | ||
|
||
namespace Allure.NUnit.Examples.CommonSteps; | ||
|
||
public static class AsyncStepsExamples | ||
{ | ||
private static readonly Random Random = new(); | ||
|
||
[AllureStep("Prepare dough")] | ||
public static async Task PrepareDough() | ||
{ | ||
await AsyncMethod($"Step {nameof(PrepareDough)}"); | ||
} | ||
|
||
[AllureStep("Cook pizza")] | ||
public static async Task CookPizza() | ||
{ | ||
await AsyncMethod($"Step {nameof(CookPizza)}"); | ||
} | ||
|
||
[AllureStep("Deliver")] | ||
public static async Task DeliverPizza() | ||
{ | ||
await AsyncMethod($"Step {nameof(DeliverPizza)}"); | ||
} | ||
|
||
[AllureStep("Pay")] | ||
public static async Task Pay() | ||
{ | ||
await AsyncMethod($"Step {nameof(Pay)}"); | ||
} | ||
private static async Task AsyncMethod(string message) | ||
{ | ||
var delay = Random.Next(50, 200); | ||
await Task.Delay(delay); | ||
Console.WriteLine($"{message}"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters