Skip to content

Nunit 3.10.1.0 + ReSharper 2020.1.4: Test execution delayed by ~60seconds #3601

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
h4kun4m4t4t4 opened this issue Jul 22, 2020 · 6 comments
Closed

Comments

@h4kun4m4t4t4
Copy link

Hi,

first of all, I'm not sure whether NUnit or Resharper might be the problem. (But problems started after upgrading to latest resharper)

When I start the execution of a test via resharper test runner, the test shows pending for about 60 seconds before even starting the relevant test code. I tracked it down to be a loading/performance issue at RuntimeFramework.cs
Type monoTouchType = Type.GetType("MonoTouch.UIKit.UIApplicationDelegate,monotouch");
The call to the above takes about 60 seconds and will then continue normal test execution.

Does anyone know what the problem might be or how I can track it further down?

What I did so far:

  • Execution with MS Test and NUnitTestadapter: works fine

  • setup a new Solution: no problem of test execution

  • When at the above position in debugger -> execute at immediate window (without the ",monotouch"): Type.GetType("MonoTouch.UIKit.UIApplicationDelegate"); --> returns immediately

@CharliePoole
Copy link
Member

The key bit you have left out is what kind of an application you are targeting. 😃 That line of code will execute differently depending on whether you are using MonoTouch or not.

To be more precise, it will execute differently depending on whether an assembly containing that UI delegate is loaded or not.

@h4kun4m4t4t4
Copy link
Author

h4kun4m4t4t4 commented Jul 23, 2020

Thanks for the info.
The application is written in C# and targeting .Net Framework 4.7.
In fact in our company we have different Solutions with the above settings... some show the delay and some not.

I did non hear about MonoTouch until yesterday, so I do not think it is involved at all. The call always returns "Null".

In the meantime I believe it might be something how the resharper testrunner orchestrates NUnit. Maybe it is something in the environment. But currently I'm lost and do not know what to look for.

EDIT:
I have tested the latest NUnit release (https://github.com/nunit/nunit/releases/tag/v3.12) and the problem is gone. (at least thus far).
I'll check if my company can update to the latest NUnit version. -> this will address the issue on my side, but maybe we can check what, the rootcause in the 3.10.1.0 is?

EDIT2:
very strange with the latest nunit release, I get a delay of about 60 to 180 seconds for all test which requires ThreadApartement.STA attribute: ([Apartment(System.Threading.ApartmentState.STA)])

File NUnitTestAssemblyRunner.cs -> in method public ITestResult Run(ITestListener listener, ITestFilter filter)
=> WaitForCompletion(Timeout.Infinite); takes ages
=> Callstack

mscorlib.dll!System.Threading.ManualResetEventSlim.Wait(int millisecondsTimeout, System.Threading.CancellationToken cancellationToken) Unknown

nunit.framework.dll!NUnit.Framework.Api.NUnitTestAssemblyRunner.Run(NUnit.Framework.Interfaces.ITestListener listener, NUnit.Framework.Interfaces.ITestFilter filter) Line 215 C#

nunit.framework.dll!NUnit.Framework.Api.FrameworkController.RunTests(System.Web.UI.ICallbackEventHandler handler, string filter) Line 325 C#

@ChrisMaddock
Copy link
Member

I suspect a PR I did 2 years ago is the reason for the change between 3.10 and 3.12 --> #3131

I have no idea what might be the cause of your current issue, I'm afraid.

@h4kun4m4t4t4
Copy link
Author

Morning,
I'm currently back to my old setup Nunit 3.10.1.0 + ReSharper 2019.2.4. This works fine so far.

Last Friday I was experimenting and tried to create a simple test project, to be able to reproduce the problem.... It is not that easy :-/.
In the end I took one of my company projects and stripped down all unnecessary code parts.
In my company all solutions and projects output-folder points to the same directory -> ~10k files (exe, dll, config, pdb, folder)

  • test project with delayed test: output-folder with about ~10k files --> show delay
  • test project with delayed test: change output directory to a unique folder (about 20 files) --> no delay

Then I tried to find out if a file maybe affects ReSharper or NUnit, by deleting chunks of 500 files. But that did not lead to clear results:

  • test project
    -- on one point the execution was not delayed anymore. But after restoring the last removed chunk it works as well.
    -- some times the execution was delayed by ~20 seconds, some times not.

The Testrunner of resharper shows only one real difference between 2019.2.4 and 2020.1.4 in the verbose log (apart from different bin folder):

  • 2019.2.4: VERBOSE Running elements from criterion: {TestAncestorCriterion: NUnit3x::A953C6C0-11F1-43E0-96F8-46C072EDBB0C::.NETFramework,Version=v4.7::TestProject.TestFixture.Foo}

  • 2020.1.4: VERBOSE Running elements from criterion: {ConjunctiveCriterion: {TestAncestorCriterion: NUnit3x::A953C6C0-11F1-43E0-96F8-46C072EDBB0C::.NETFramework,Version=v4.7::TestProject.TestFixture.Foo}, {TestAncestorCriterion: NUnit3x::A953C6C0-11F1-43E0-96F8-46C072EDBB0C::.NETFramework,Version=v4.7::TestProject.TestFixture.Foo}}
    => I guess this would be some thing to ask in the resharper forum

@ChrisMaddock
Copy link
Member

@h4kun4m4t4t4 I agree you need to follow this one up with the ReSharper team. Those log messages you've shared are from ReSharper, not NUnit, but sound like they might point to the difference.

I'll close this issue, as I don't think there's any more we can do here - but please open a new one if you can trace a cause back to NUnit. 👍

@rprouse
Copy link
Member

rprouse commented Feb 21, 2023

I believe this was fixed by #4034

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants