Error when running xunit tests, AssemblyRunner.Start() ambiguous method
A recent Linqpad update caused this issue.
Error when executing xunit tests in a query. Simply create a new empty query, add Xunit test support and then run. Error is:
CS0121 The call is ambiguous between the following methods or properties: 'AssemblyRunner.Start(string, bool?, TestMethodDisplay?, TestMethodDisplayOptions?, bool?, bool?, int?, bool?)' and 'AssemblyRunner.Start(string, bool?, TestMethodDisplay?, TestMethodDisplayOptions?, bool?, bool?, int?, bool?, ParallelAlgorithm?)'
Environment:
- Linqpad v8.4.11 beta
- Windows 11
The offending line of code in the xunit.linq is:
static TestResultSummary[] RunTests(bool quietly = false, bool reportFailuresOnly = false, Func<Xunit.Abstractions.ITestCase, bool> filter = null) { //stuff... runner.Start(); done.Wait(); return tests; }
I fixed it with a specific call to the overload accepting the options instance (since the other two overloads are obsolete and complex) Not sure if this is correct but it works:
var opt = new AssemblyRunnerStartOptions(); runner.Start(opt);
Comments
-
This issue is actually caused by an xUnit update.
The difficulty with rolling out a workaround in LINQPad is that it will break with older versions of xUnit that lack that type. I'm hoping they're going to release the fix soon.
-
Thanks for the update Joe. In the meantime, will my fix be reasonable measure? We are using the latest Xunit and DotNet versions for all projects:
var opt = new AssemblyRunnerStartOptions(); runner.Start(opt);