testfx icon indicating copy to clipboard operation
testfx copied to clipboard

After upgrade from 2.2.3 to 2.2.5 and later - failed to discover tests in class

Open Sl1ckR1ck opened this issue 3 years ago • 3 comments

Hi after upgrading some project to the latest version (2.2.8) we start to notice many tests were failing to be discovered (almost 50% are failing).

After further investigate I tried many versions of TestAdapter and found that the problem start when trying to move from 2.2.3 (working version) to 2.2.4 (breaks).

I understand that 2.2.4 is deprecated, but I tried all other versions after that and the same issue exists.

Im not too sure what to provide as a repro project since it seems to occur only because of the version upgrade and can't share our source code.

this is the error i get: MSTestAdapter failed to discover tests in class 'BlablaTests' of assembly 'C:...s\bin\Debug\net48\Core.Wpf.UnitTests.dll' because Object reference not set to an instance of an object..

Sl1ckR1ck avatar Dec 03 '21 20:12 Sl1ckR1ck

Here is the test log file if it may help logs.host.21-12-03_15-33-38_85307_24 (1).txt

Sl1ckR1ck avatar Dec 03 '21 21:12 Sl1ckR1ck

We were seeing similar test discovery issues on v2.2.5+. For us, we had a missing top-level namespace --- i.e., some source files for the test assembly had a top-level namespace and some didn't. Ensuring that all the source files for the test assembly had an explicit top-level namespace made the discovery issue to go away on v2.2.5+ for us.

jpwarner67 avatar Feb 18 '22 03:02 jpwarner67

Yes! Thanks that was it.

Some of my unit tests projects had no default namespace defined. After entering one the problem was gone.

I guess this should be fixed as it is very annoying and a bit hard to notice that some unit tests have gone missing...

Sl1ckR1ck avatar Feb 25 '22 21:02 Sl1ckR1ck

This is not linked to the test ID generation but was linked to a bug in hierarchy processing. Updating our object model dependency fixed the issue.

I will close the issue and confirm fix will be included in v3.

Evangelink avatar Oct 13 '22 08:10 Evangelink