Skip to content

Delay between tests #908

Answered by thomhurst
borislavml asked this question in Q&A
Oct 15, 2024 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

Creating a custom TestExecutor should be able to achieve this.

public class DelayedExecutor : GenericAbstractExecutor
{
    private static bool _hasRun;

    protected override async Task ExecuteAsync(Func<Task> action)
    {
        if (Interlocked.Exchange(ref _hasRun, true))
        {
            await Task.Delay(10_000);
        }

        await action();
    }
}
[TestExecutor<DelayedExecutor>]
public class MyTests
{
    [Test]
    public async Task Test1()
    {
        // do some stuff which results in a message sent on a queue
    }

    [Test]
    [DependsOn(nameof(Test1))]
    public async Task Test2()
    {
        // wait on a queue to read from the messsage as a result of the …

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@borislavml
Comment options

Answer selected by borislavml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants