.NET 3.5 [AssemblyInitialize] attribue, TestContext and NUnit test runner
Hello!
We are currently migrating our projects from .NET 2.0 to .NET 3.5 and found following issue:
To run tests on TeamCity we are using following entry in TeamCity proj file:
<UsingTask TaskName="NUnit" AssemblyFile="$(teamcity_dotnet_nunitlauncher_msbuild_task)" />
Then we are running it using:
<Target Name="CoreTest">
<NUnitTeamCity Assemblies="$(OutDir)\Assembly1.dll;$(OutDir)\Assembly2.dll" />
</Target>
We also use [AssemblyInitialize] attribute on method to run code before test run:
[AssemblyInitialize]
public static void StartUpMethodTestContext context)
{
}
On .NET 2.0 everything was fine - tests were running OK.
Since we migrated to 3.5 we are not able to run [AssemblyInitialize] method anymore from TeamCity. We are getting following error:
Object of type 'NUnit.Core.Builders.VstsTestFixture+NUnitTestContext' cannot be converted to type 'Microsoft.VisualStudio.TestTools.UnitTesting.TestContext'.
It seems that NUnit runner is passing NUnitTestContext object (but it should pass TestContext from MS Framework). As I wrote on .NET 2.0 everything was OK.
Is it possible to fix it or change anything in code to make it run?
Best Regards!
Please sign in to leave a comment.
Nevermind I found solution: