Search code examples
.net-corenunitintegration-testingnunit-3.0

Moved NUnit 3 test to new project results in poor performance


Setup of dotnet 7 project:

  • <namespace>.Api
  • <namespace>.Api.Test
  • some others

I started with an integration test, within <namespace>.Api.Test project. The integration test basically starts the whole application (<namespace>.Api), creates a HttpClient and communicates to the REST Api from <namespace>.Api project.

After first good results, I decided to create an own project for integration tests:

  • <namespace>.Api.Integration ... where the new project has same packages as <namespace>.Api.Test.

Dragged the relevant class in VS 2022 to <namespace>Api.Integration (which copies the file), renamed the test class + method to some unique values.

Now, when starting the new version of the test, application startup takes 2 minutes, whereas starting from old <namespace>.Api.Test only takes 7 seconds. During startup, a bunch of db operations is performed (and logged) sequentially. In both cases, same db operations are performed against same fresh and local database.

What's happening in the test looks very well.

Do you have any idea what could be the issue here?

Already tried:

  • updates of VS
  • clear bin/obj folders
  • update of Nunit to 3.14.0 and NUnit3TestAdapter to 4.5.0
  • using dotnet test has same results
  • disable Windows Firewall (which asked for permission when hosting REST Api)

Solution

  • Found the issue myself:
    I managed that server app, started from integration test in a dedicated thread, started another thread that was stuck in an endless loop searching for files on hard disk without any break.
    It seems that this loop consumed too much CPU which slowed down the whole system.