nunit / teamcity-event-listener

NUnit Engine extension that helps integration with teamcity
MIT License
11 stars 10 forks source link

Added net core support #75

Closed oldmine closed 3 years ago

oldmine commented 3 years ago

In NUnit Console Runner 3.12 added net core support, but old extensions is not compatible, because they build for net framework. Extension was updated to work with new version of console runner on net core.

Changes:

oldmine commented 3 years ago

Please, can someone review pull request? @NikolayPianikov @CharliePoole

NikolayPianikov commented 3 years ago

@oldmine a build fails for a cloned repo. I suppose you should add .WithRestore() for MSBuildSettings in build.cake . Also I asked about net20 previously. I suppose nuget packages will contain net3.5 version only. Is it expected result?

oldmine commented 3 years ago

@NikolayPianikov Thanks for answer. Build was fail on your local machine or CI? Tests and checks passed successful.

About targeting netstandard: For new version of Console Runner extension packages should target netstandard2.0 to be compatible and works on net framework and net core. If extension was build for net framework and run net core runner, extension will be not found and not worked.

Example that extension that build for netstandrad was work with NUnit.ConsoleRunner 3.10 on netframework image_2020-11-20_18-39-19

Example that extension that build for netstandrad was work with NUnit.ConsoleRunner 3.12-beta1 on netcore3.1 image_2020-11-20_18-40-45

NikolayPianikov commented 3 years ago

Yes, I cloned the repo from your fork and started the build from scratch. Build doesn't work locally.

Is it worth packing 2 versions of an extension into the nuget package in different directories? like:

CharliePoole commented 3 years ago

@NikolayPianikov Putting versions in directories like that seems right to me. It's true that the current console runner is in two versions and each one could use a different package, but I'm pretty sure that's not the way it will always be for nunit-console.

And other runners are free to work differently - running under one platform but supporting other platforms for execution out of process. That's how my own runner works. So using a runner like that, you would probably prefer to install a single package that included all supported targets.

ChrisMaddock commented 3 years ago

Multiple platforms in a single NuGet package was the original design intention. :smile: I think an additional .addins text file is also needed in \tools\ to make it work too - although someone was recently saying they'd not needed that. It's been a good few years since we implemented this functionality in the engine - so my memory may well be wrong!

See this post for more of an explanation on the structure the engine is expecting --> https://github.com/nunit/nunit-console/issues/806#issuecomment-669513731

NikolayPianikov commented 3 years ago

I've created a nuget package containing:

.addins is a file:

netstandard2.0/
net20/

and found several issues:

Runtime Environment OS Version: Microsoft Windows NT 6.2.9200.0 Runtime: .NET Framework CLR v4.0.30319.42000

Installed Extensions Extension Point: /NUnit/Engine/NUnitV2Driver Extension Point: /NUnit/Engine/TypeExtensions/IService Extension Point: /NUnit/Engine/TypeExtensions/ITestEventListener Extension: NUnit.Engine.Listeners.TeamCityEventListener(.NET 4.0) Version: 1.0.8.0 Path: C:\Projects\NUnit\aa\nunit\NUnit.Extension.TeamCityEventListener.1.0.8\tools\netstandard2.0\teamcity-event-listener.dll Extension Point: /NUnit/Engine/TypeExtensions/IDriverFactory Extension Point: /NUnit/Engine/TypeExtensions/IProjectLoader Extension Point: /NUnit/Engine/TypeExtensions/IResultWriter


- NUnit.ConsoleRunner.3.12.0-beta1\tools\nunit3-console.exe fails with error ```Could not load file or assembly 'nunit.engine.api, Version=3.0.0.0, Culture=neutral, PublicKeyToken=2638cd05610744eb' or one of its dependencies. The system cannot find the file specified.``` when _tools/net20_ does not containt nunit.engine.api.dll with appropritae version.
- NUnit.ConsoleRunner.3.12.0-beta1\tools\nunit3-console.exe fails with error 

System.InvalidCastException : Unable to cast object of type 'NUnit.Engine.Listeners.TeamCityEventListener' to type 'NUnit.Engine.ITestEventListener'.

--InvalidCastException Unable to cast object of type 'NUnit.Engine.Listeners.TeamCityEventListener' to type 'NUnit.Engine.ITestEventListener'. at NUnit.Engine.Services.ExtensionService.d__24`1.MoveNext() at NUnit.Engine.Runners.MasterTestRunner.RunTests(ITestEventListener listener, TestFilter filter) at NUnit.Engine.Runners.MasterTestRunner.Run(ITestEventListener listener, TestFilter filter) at NUnit.ConsoleRunner.ConsoleRunner.RunTests(TestPackage package, TestFilter filter) in C:\Projects\NUnit\nunit-console\src\NUnitConsole\nunit3-console\ConsoleRunner.cs:line 218 at NUnit.ConsoleRunner.ConsoleRunner.Execute() in C:\Projects\NUnit\nunit-console\src\NUnitConsole\nunit3-console\ConsoleRunner.cs:line 120 at NUnit.ConsoleRunner.Program.Main(String[] args) in C:\Projects\NUnit\nunit-console\src\NUnitConsole\nunit3-console\Program.cs:line 135


when _tools/net20_ contains _nunit.engine.api.dll_ with version 3.11.1 from the nuget package
NikolayPianikov commented 3 years ago

@ChrisMaddock could you suggest what I am doing wrong

ChrisMaddock commented 3 years ago

Hi @NikolayPianikov,

Your package structure looks as I'd expect.


Lastly, point one is interesting. I think the behaviour here isn't exactly what we intended, but roughly correct.

I suspect you're running the Console on .NET 4.6.2 or later? The intended behaviour is that the engine discovers all valid extensions, and works out from those which ones have target frameworks it is able to load. The engine should then pick the extension for the "highest possible target framework" - so in this case, .NET Standard 2.0 over .NET 2.0. If your extension was to target .NET Core instead of .NET Standard, then the .NET Framework Console would ignore it and select the net20 version instead.

I think there's actually a bug in the code that the engine is only working out which extension is "best" by comparing the two version numbers (e.g. 2.0 vs 2.0) - but the end result is as intended. I presume it also doesn't matter which version is selected for the TC extension - are the two versions functionally identical?

k15tfu commented 3 years ago

@NikolayPianikov Hi! When will the new package be available?

NikolayPianikov commented 3 years ago

@ChrisMaddock yes versions are identical. I confirm that NUnit.ConsoleRunner.3.12.0-dev-04961 on myget works fine.

NikolayPianikov commented 3 years ago

@ChrisMaddock when you are planning to release In NUnit Console Runner 3.12?

NikolayPianikov commented 3 years ago

@k15tfu I suppose few days

ChrisMaddock commented 3 years ago

Thanks @NikolayPianikov. Console 3.12 will probably be in the new year now, my time up until the end of the year will be limited now. Would recommend using the MyGet build of the console, for anyone who wants to start using this straight away. 🙂

NikolayPianikov commented 3 years ago

I've published the TeamCity extension 1.0.8 containing netstandard2.0. It works with release versions and with a MyGet build