Run Unit tests in Rider does not work with Unity 2017.1.2p4

When we upgraded to Unity 2017.1 we now noticed that Unit tests written inside a Unity3D project do not work anymore when running them from Rider IDE. We are using Rider 2017.3 and it works with Unity 5.5.3p4. But for Unity 2017.x based projects I get this error when trying to run Unit tests within Rider: System.MissingMethodException: Method 'Mono.Cecil.TypeDefinition.get_Interfaces' not found.

Any ideas? I tried to use different Mono backends and different NUnit settings but nothing seemed to work. This is very unfortunate because it is so much nicer and faster to test the tests in Rider instead of switching to Unity.

Repro steps:

 

  1. Create new Unity project
  2. Create script with [Test] method in it.
  3. Start Solution via Rider
  4. Run Unit tests
  5. Observe "Inconclusive" status in the Unit Tests window

 

Log:

 

12:39:38.291 |I| BuildStage started
12:39:38.291 |I| Build policy: Automatic
12:39:53.646 |I| 4 projects built
12:39:53.646 |V| Assembly-CSharp
Assembly-CSharp-firstpass
Assembly-CSharp-Editor
Assembly-CSharp-Editor-firstpass
12:39:53.646 |I| BuildStage completed
12:39:53.670 |I| RefreshProjectPropertiesStage started
12:39:53.670 |I| RefreshProjectPropertiesStage completed
12:39:53.670 |I| DiscoveryStage started
12:39:53.670 |I| Test exploration required for 1 projects
12:39:53.670 |V| Assembly-CSharp-Editor
12:39:53.924 |I| DiscoveryStage completed
12:39:53.924 |I| BuildPipelineStage started
12:39:53.924 |I| BuildPipelineStage completed
12:39:53.924 |I| ApplyRulesStage started
12:39:53.926 |I| Got 1 elements (1 explicit) to run
12:39:53.926 |V| Marking 1 elements as Pending
12:39:53.927 |V| Marking elements as Pending completed
12:39:53.927 |V| Distributing 1 elements into runs
12:39:53.933 |V| Distributing elements completed
12:39:53.933 |I| Created 1 unit-test runs
12:39:53.933 |I| ApplyRulesStage completed
12:39:53.933 |I| RunTestsStage started
12:39:53.933 |V| Running up to 1 unit-test runs in parallel
12:39:53.933 |I| Run: 70b5774d-9b99-485e-a333-6c364a037400 - Started
12:39:53.933 |V| Provider: NUnit 3x
Project: None
Target Framework: .NETFramework,Version=v3.5
Strategy: JetBrains.ReSharper.UnitTestProvider.nUnit.NUnitOutOfProcessUnitTestRunStrategy
Runtime Enviroment:
Platform Type: x64
Platform Version: v2_0
12:39:53.934 |I| [ProcessStartInfoPatchResult]
Original request: FrameworkRequest (UseInternal: False, UseMono: False, MonoDebugMode: True, MonoPrefer64Bit: True)
Success: True
ErrorMessage: <Empty>
Original StartInfo: FileName = '/Users/robin.fischer/Library/Application Support/JetBrains/Toolbox/apps/Rider/ch-0/173.3994.1125/Rider 2017.3.app/Contents/lib/ReSharperHost/JetBrains.ReSharper.TaskRunner.x64.exe', Arguments = '"127.0.0.1" "61785" "70b5774d-9b99-485e-a333-6c364a037400"', WorkDir = '/Users/robin.fischer/Library/Application Support/JetBrains/Toolbox/apps/Rider/ch-0/173.3994.1125/Rider 2017.3.app/Contents/lib/ReSharperHost'
Patched StartInfo: FileName = '/Library/Frameworks/Mono.framework/Versions/Current/bin/mono', Arguments = '--arch=64 --debug "/Users/robin.fischer/Library/Application Support/JetBrains/Toolbox/apps/Rider/ch-0/173.3994.1125/Rider 2017.3.app/Contents/lib/ReSharperHost/JetBrains.ReSharper.TaskRunner.x64.exe" "127.0.0.1" "61785" "70b5774d-9b99-485e-a333-6c364a037400"', WorkDir = '/Users/robin.fischer/Library/Application Support/JetBrains/Toolbox/apps/Rider/ch-0/173.3994.1125/Rider 2017.3.app/Contents/lib/ReSharperHost'

12:39:53.935 |I| Starting process: /Library/Frameworks/Mono.framework/Versions/Current/bin/mono --arch=64 --debug "/Users/robin.fischer/Library/Application Support/JetBrains/Toolbox/apps/Rider/ch-0/173.3994.1125/Rider 2017.3.app/Contents/lib/ReSharperHost/JetBrains.ReSharper.TaskRunner.x64.exe" "127.0.0.1" "61785" "70b5774d-9b99-485e-a333-6c364a037400"
12:39:54.018 |I| Started process with pid 34153
12:39:54.612 |E| System.MissingMethodException: Method 'Mono.Cecil.TypeDefinition.get_Interfaces' not found.
System.MissingMethodException: Method 'Mono.Cecil.TypeDefinition.get_Interfaces' not found.
at NUnit.Engine.Services.ExtensionService.FindExtensionsInAssembly (NUnit.Engine.Services.ExtensionAssembly assembly) [0x001a6] in <7b0953727751470ab10f0e0b547b85ae>:0
at NUnit.Engine.Services.ExtensionService.StartService () [0x00080] in <7b0953727751470ab10f0e0b547b85ae>:0
at NUnit.Engine.Services.ServiceManager.StartServices () [0x00087] in <7b0953727751470ab10f0e0b547b85ae>:0
at NUnit.Engine.TestEngine.Initialize () [0x000fd] in <7b0953727751470ab10f0e0b547b85ae>:0
at NUnit.Engine.TestEngine.GetRunner (NUnit.Engine.TestPackage package) [0x00012] in <7b0953727751470ab10f0e0b547b85ae>:0
at JetBrains.ReSharper.UnitTestRunner.nUnit30.BuiltInNUnitRunner+<>c__DisplayClass1.<RunTests>b__0 () [0x00017] in <43feebf86fe44560828e651dc995036d>:0
at JetBrains.ReSharper.UnitTestRunner.nUnit30.BuiltInNUnitRunner.WithExtensiveErrorHandling (JetBrains.ReSharper.TaskRunnerFramework.IRemoteTaskServer server, System.Action action) [0x00000] in <43feebf86fe44560828e651dc995036d>:0

12:39:54.639 |I| Process /Library/Frameworks/Mono.framework/Versions/Current/bin/mono:34153 has exited
12:39:54.640 |I| Run: 70b5774d-9b99-485e-a333-6c364a037400 - Completed
12:39:54.640 |I| RunTestsStage completed
12:39:54.641 |I| Finishing run
12:39:54.641 |W| Element Onyx.Tests.Editor.TestSetupFixture was left pending after its run completion.
12:39:54.641 |W| Element Onyx.Tests.Editor.Game.Common.SeasonalEvents.SeasonalEventsDataProviderTest was left pending after its run completion.
12:39:54.641 |W| Element Onyx.Tests.Editor.Game.Common.SeasonalEvents.SeasonalEventsDataProviderTest.Event_with_other_state_is_not_active was left pending after its run completion.
12:39:54.641 |I| Run is finished

0
9 comments
Official comment

The problem is that Unity is using a custom build of nunit that is intended to run tests in the Unity editor instance, and causes these errors when run in a standalone test runner. They introduced this custom build in 5.6, as I understand it.

Rider 2017.3 should support it, however. Rider installs a Unity Editor plugin into your project, which (amongst other things) will modify the reference to nunit.framework.dll in the generated project files. Instead of referencing Unity's custom version, we add a reference to a standard, compatible version that we ship with Rider (and copy into your Library folder). This is only used for building locally in Rider and running tests.

So, it should be working - do you have the Rider plugin copied into your project? There should be a file called Unity3dRider.cs. As long as it's there, it should be running and modifying the project files appropriately (and it will make sure the project files are in sync when you first open Unity, too).

Avatar
Permanently deleted user

Hi Matt,

 

thank you for your quick response! 

What you describe is happening but it still fails when starting the unit tests.

In my .csproj files the references are pointing to <PROJECT_PATH>/Library/resharper-unity-libs/nunit3.5.0/nunit.framework.dll

The Rider plugin is copied automatically by Rider to Assets/Plugins/Editor/JetBrains/Unity3DRider.cs

Test Project: https://www.dropbox.com/s/mp39eoa5k9u7cn6/TestProject.zip?dl=0 . There is also a log file inside the .zip

Unity Version: 2017.1.2p4
Rider version: JetBrains Rider 2017.3
Build #RD-173.3994.1125, built on December 26, 2017
JRE: 1.8.0_152-release-1024-b10 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Mac OS X 10.12.6

 

0
Avatar
Permanently deleted user

Also, these are my Rider Settings regarding Unit testing:



0

Thanks for the sample project. I've just tried it and got exactly the same results. Then I did a clean build (well, moved Temp/bin/Debug out of the way) and it all started working again. I'm not sure what the difference is - perhaps an old version was hanging around.

Also, I was testing with Unity 2017.3.0p1, I don't know if that makes a difference.

Let me know if cleaning the project helps.

0
Avatar
Permanently deleted user

Unfortunately that didn't do the trick. I tried cleaning my main Unity project no luck. Cleaned the Test project, also no luck. With cleaning I mean: In Rider: Build->Clean Solution and I deleted the <PROJECT_DIR>/Temp/bin directory.

I installed Unity 2017.3.0p1 and created a new project with that. That works. I diffed the build result (<PROJECT_DIR>/Temp/bin) between 2017.1.2p4 (left) and 2017.3.0p1 (right). There are some interesting changes:

I guess I have to wait until we upgrade our Unity version. For the meantime I couldn't get it to work. The Mono.Cecil version shipped with Unity ( in our version ) and build into this Debug directory seems to be incompatible with the nunit.framework.dll that the Rider plugin provides. Maybe you can try it with our Unity version on your machine?
I tried it on a colleagues machine and he had the same issue. But of course all our dev environments are setup nearly the same way.

0

There is an additional issue with the mono.cecil.dll file - as you say, there are multiple versions and they are incompatible. I believe this issue is fixed in Rider 2017.3.1, which is a maintenance release that we should be releasing soon.

0
Avatar
Permanently deleted user

Thanks for the update, I will try out the new Rider version when it is available and report back.

0
Avatar
Permanently deleted user

I've run into this issue in the 2018.1 EAP (more version information below) after having it working just fine in 2017.3.  Here is the log output: https://gist.github.com/ericallam/a3c94b8a3683bc4396165f1e0991fa86

 

Build #RD-181.4379.974, built on April 10, 2018
Rider EAP User
Expiration date: May 10, 2018
JRE: 1.8.0_152-release-1136-b23 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
macOS 10.13.4

0
Avatar
Permanently deleted user

Just discovered that when running tests with Unity open leads to the above behaviour. If Unity is NOT running, then tests run fine in Rider.

0

Please sign in to leave a comment.