Build/Test Issues

Xunit.DependencyInjection and OperationCanceledException

Started by GreenMoose on 1,439 views

[v5.10.0.7]

I bumped into a test project that is using Xunit.DependencyInjection which is quite impossible to run with NCrunch.

I tried creating a separate project with just below content, and the test fails if NCrunch runs it in an existing test runner process (but succeeds when running in a new process).


//XUnit                                  2.9.2
//xunit.runner.visualstudio      2.8.2
//Xunit.DependencyInjection   9.5.0

public class Startup
{
    
        public void ConfigureServices(IServiceCollection services)
        {
            //services.AddTransient<IDependency, DependencyClass>();
        }
    
}

public class DummyTest
{
    [Fact]
    public void DoSomething()
    {
/* test error when running in existing test runner process:
System.OperationCanceledException: The operation was canceled.
   at System.Threading.CancellationToken.ThrowOperationCanceledException()
   at System.Threading.CancellationToken.ThrowIfCancellationRequested()
   at Microsoft.Extensions.Hosting.Internal.Host.StartAsync(CancellationToken cancellationToken)
   at Xunit.DependencyInjection.DependencyInjectionTestFrameworkExecutor.RunTestCases(IEnumerable`1 testCases, IMessageSink executionMessageSink, ITestFrameworkExecutionOptions executionOptions) in S:\GitHub\Xunit.DependencyInjection\src\Xunit.DependencyInjection\DependencyInjectionTestFrameworkExecutor.cs:line 51
*/
    }
}


Is this a known issue and/or workaround for this behavior?

Thanks.
FWIW, I probably can remove the package all together for this project so it isn't a big issue for now, but it seems to be quite a popular nuget package so it maybe can be interesting to look into if it is NCrunch's behavior or the package itself that is causing it.
Hi, thanks for sharing this issue.

This tool seems to be deeply integrated with Xunit. It implements its own runner classes and changes the behaviour of the test framework itself. I don't know of a way to use this with NCrunch out of the box. We'd probably need to undertake a small project to introduce a separate test adapter for it, which probably isn't worth the effort given that Xunit v3 changes all of this anyway.

Sorry, we can't support this tool.

Post a reply

Log in to reply.