Skip to content

Can Fixture.InitializeAsync Code execute parallelly with another test collection? #2929

Answered by bradwilson
JinsPeter asked this question in Question
Discussion options

You must be logged in to vote

Sorry, I just noticed you mentioned InitializeAsync. The sample changes, but the behavior is still the same:

using System;
using System.Threading.Tasks;
using Xunit;

namespace Empty;

public sealed class Fixture1 : IAsyncLifetime
{
	public Task InitializeAsync () { Console.WriteLine("Fixture1.InitializeAsync"); return Task.CompletedTask; }
	public Task DisposeAsync() { Console.WriteLine("Fixture1.DisposeAsync"); return Task.CompletedTask; }
}

[CollectionDefinition(nameof(Collection1))]
public class Collection1 : ICollectionFixture<Fixture1> { }

[Collection(nameof(Collection1))]
public class TestClass1a
{
	[Fact]
	public void TestMethod() => Console.WriteLine("TestClass1a.TestMethod");
}

Replies: 2 comments 1 reply

Comment options

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

Answer selected by JinsPeter
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants