You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This will affect any test that loads at runtime an assembly containing classes that implement specific interface types (as in plugin system / dependency injection). The interface type implemented by the class will not pass equality against a compile-time reference to that type.
NUnit and NUnit3TestAdapter versions: NUnit: 3.13.3, NUnit3TestAdapter: 4.4.0 (works fine with 4.3.1)
Visual Studio edition and full version number: VS Enterprise 2022, 17.4.1
A short repro, preferably attached or pointing to a git repo or gist: See below
What .net platform and version is being targeted: .NET 6.0
Steps to reproduce
Create a "Specification" class project containing an interface called IService:
public interface IService
{
string Hello();
}
Create an "Implementation" class project referencing the Specification project with a class called Service:
public class Service : IService
{
public string Hello() => "Hi";
}
Create an NUnit test project referencing the Specification project.
Add the following test class:
[TestFixture]
public class Tests
{
[Test]
public void Test()
{
var assembly = AssemblyLoadContext.Default.LoadFromAssemblyPath(@"C:\Path\To\Implementation.dll");
var serviceType = assembly.GetExportedTypes().First(t => t.Name == "Service");
Assert.That(serviceType.GetInterfaces().Single(), Is.EqualTo(typeof(IService)));
}
}
Update the NUnit3TestAdapter package to 4.4.0
Build the solution.
Update the path to the built Implementation.dll
Run the test.
The test fails. On any version of NUnit3TestAdapter before 4.4.0 it passes.
Hotfix version 4.4.2, nearly identical to the alpha version attached yesterday, is now released. The difference from the attached version is that the Microsoft.Extensions.DependencyModel is not included in the adapter package. It is not needed there, so it was removed. The release notes is here https://docs.nunit.org/articles/vs-test-adapter/AdapterV4-Release-Notes.html (includes some more explanations) and the package is uploaded to nuget https://www.nuget.org/packages/NUnit3TestAdapter/4.4.2. Thanks, everyone for reporting and providing repros!
This will affect any test that loads at runtime an assembly containing classes that implement specific interface types (as in plugin system / dependency injection). The interface type implemented by the class will not pass equality against a compile-time reference to that type.
Steps to reproduce
IService
:Service
:NUnit3TestAdapter
package to 4.4.0The test fails. On any version of
NUnit3TestAdapter
before 4.4.0 it passes.The test solution is attached.
LoadAssemblyTest.zip
The text was updated successfully, but these errors were encountered: