mirror of
https://github.com/LD-Reborn/Berufsschule_HAM.git
synced 2025-12-20 06:51:55 +00:00
Added RetryFactAttribute
This commit is contained in:
@@ -42,7 +42,7 @@ public class AssetsPageTests : IDisposable
|
|||||||
css.ForEach(selector => _driver.FindElement(By.CssSelector(selector)));
|
css.ForEach(selector => _driver.FindElement(By.CssSelector(selector)));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[RetryFact(5)]
|
||||||
public void AssetsPage_ShouldCreateAndShowDetailAndUpdateAndDeleteAsset()
|
public void AssetsPage_ShouldCreateAndShowDetailAndUpdateAndDeleteAsset()
|
||||||
{
|
{
|
||||||
AppHelper.Login(_driver);
|
AppHelper.Login(_driver);
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ public class GroupsPageTests : IDisposable
|
|||||||
css.ForEach(selector => _driver.FindElement(By.CssSelector(selector)));
|
css.ForEach(selector => _driver.FindElement(By.CssSelector(selector)));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[RetryFact(5)]
|
||||||
public void GroupsPage_ShouldCreateAndUpdateAndDeleteGroup()
|
public void GroupsPage_ShouldCreateAndUpdateAndDeleteGroup()
|
||||||
{
|
{
|
||||||
string randomName = $"RESERVED_TEST_{AppHelper.GetRandomName()}";
|
string randomName = $"RESERVED_TEST_{AppHelper.GetRandomName()}";
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ public class InventoryPageTests : IDisposable
|
|||||||
_driver.FindElement(By.Id("scanBarcodeButton"));
|
_driver.FindElement(By.Id("scanBarcodeButton"));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[RetryFact(5)]
|
||||||
public void InventoryPage_ShouldShowCompleteViewModal()
|
public void InventoryPage_ShouldShowCompleteViewModal()
|
||||||
{
|
{
|
||||||
AppHelper.Login(_driver);
|
AppHelper.Login(_driver);
|
||||||
@@ -62,7 +62,7 @@ public class InventoryPageTests : IDisposable
|
|||||||
Assert.NotEmpty(_driver.FindElement(By.Id("detailPurchaseBy")).GetAttribute("value") ?? "");
|
Assert.NotEmpty(_driver.FindElement(By.Id("detailPurchaseBy")).GetAttribute("value") ?? "");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[RetryFact(5)]
|
||||||
public void InventoryPage_ShouldShowSuccessToastOnInformationCorrect()
|
public void InventoryPage_ShouldShowSuccessToastOnInformationCorrect()
|
||||||
{
|
{
|
||||||
AppHelper.Login(_driver);
|
AppHelper.Login(_driver);
|
||||||
@@ -79,7 +79,7 @@ public class InventoryPageTests : IDisposable
|
|||||||
Assert.True(AppHelper.TryRetryFindSuccessToast(_driver));
|
Assert.True(AppHelper.TryRetryFindSuccessToast(_driver));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[RetryFact(5)]
|
||||||
public void InventoryPage_ShouldShowSuccessToastOnInformationUpdate()
|
public void InventoryPage_ShouldShowSuccessToastOnInformationUpdate()
|
||||||
{
|
{
|
||||||
AppHelper.Login(_driver);
|
AppHelper.Login(_driver);
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ public class LocationsPageTests : IDisposable
|
|||||||
css.ForEach(selector => _driver.FindElement(By.CssSelector(selector)));
|
css.ForEach(selector => _driver.FindElement(By.CssSelector(selector)));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[RetryFact(5)]
|
||||||
public void LocationsPage_ShouldCreateAndUpdateAndDeleteGroup()
|
public void LocationsPage_ShouldCreateAndUpdateAndDeleteGroup()
|
||||||
{
|
{
|
||||||
string randomName = $"RESERVED_LOCATION_{AppHelper.GetRandomName()}";
|
string randomName = $"RESERVED_LOCATION_{AppHelper.GetRandomName()}";
|
||||||
|
|||||||
49
tests/Berufsschule_HAM.E2ETests/RetryFactAttribute.cs
Normal file
49
tests/Berufsschule_HAM.E2ETests/RetryFactAttribute.cs
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
using System;
|
||||||
|
using Xunit;
|
||||||
|
using Xunit.Abstractions;
|
||||||
|
using Xunit.Sdk;
|
||||||
|
|
||||||
|
namespace Berufsschule_HAM.E2ETests;
|
||||||
|
|
||||||
|
[XunitTestCaseDiscoverer("YourNamespace.RetryFactDiscoverer", "YourAssemblyName")]
|
||||||
|
public class RetryFactAttribute(int maxRetries = 5) : FactAttribute
|
||||||
|
{
|
||||||
|
public int MaxRetries { get; } = maxRetries;
|
||||||
|
}
|
||||||
|
|
||||||
|
public class RetryTestCase : XunitTestCase
|
||||||
|
{
|
||||||
|
private int _maxRetries;
|
||||||
|
|
||||||
|
[Obsolete("Called by the de-serializer", true)]
|
||||||
|
public RetryTestCase() { }
|
||||||
|
|
||||||
|
public RetryTestCase(int maxRetries, ITestMethod testMethod)
|
||||||
|
: base(new NullMessageSink(), TestMethodDisplay.Method, TestMethodDisplayOptions.None, testMethod)
|
||||||
|
{
|
||||||
|
_maxRetries = maxRetries;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override async Task<RunSummary> RunAsync(
|
||||||
|
IMessageSink diagnosticMessageSink,
|
||||||
|
IMessageBus messageBus,
|
||||||
|
object[] constructorArguments,
|
||||||
|
ExceptionAggregator aggregator,
|
||||||
|
CancellationTokenSource cancellationTokenSource)
|
||||||
|
{
|
||||||
|
var summary = new RunSummary();
|
||||||
|
|
||||||
|
for (int i = 1; i <= _maxRetries; i++)
|
||||||
|
{
|
||||||
|
var result = await base.RunAsync(
|
||||||
|
diagnosticMessageSink, messageBus, constructorArguments, aggregator, cancellationTokenSource);
|
||||||
|
|
||||||
|
summary.Aggregate(result);
|
||||||
|
|
||||||
|
if (result.Failed == 0)
|
||||||
|
break; // success, stop retrying
|
||||||
|
}
|
||||||
|
|
||||||
|
return summary;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -42,7 +42,7 @@ public class UsersPageTests : IDisposable
|
|||||||
css.ForEach(selector => _driver.FindElement(By.CssSelector(selector)));
|
css.ForEach(selector => _driver.FindElement(By.CssSelector(selector)));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[RetryFact(5)]
|
||||||
public void UsersPage_ShouldCreateAndShowDetailAndUpdateAndDeleteUser()
|
public void UsersPage_ShouldCreateAndShowDetailAndUpdateAndDeleteUser()
|
||||||
{
|
{
|
||||||
AppHelper.Login(_driver);
|
AppHelper.Login(_driver);
|
||||||
|
|||||||
Reference in New Issue
Block a user