Build/Test Issues

Test method must be public

Started by MatthewSteeples on 1,855 views

We're receiving a failure for one of our tests, and the entire Trace Output of it is below:

NCrunch: This test was executed on server '(local)'

Test method must be public


We're unable to work out what's causing this problem, and we're only able to sort of reproduce it in a minimal solution currently, so I'm posting the details of it here to see if this makes any sense.

  • We have an abstract class with a handful of test methods on it decorated with TestMethod attributes.
  • The abstract class does not have a TestClass attribute.
  • There are 3 concrete classes which inherit from the abstract class and have the TestClass attribute on them. These are nested within other public classes.
  • Each of the 3 concrete classes have no test methods themselves, just the ones inherited from the abstract class.
  • Each of the 3 concrete classes passes a different parameter into the abstract class's constructor (as this is what is being tested)
  • 2 of the 3 concrete class have no problem running tests
  • In the 3rd concrete class, the 2nd test fails to run with the above error
  • By "the 2nd test" I literally mean the 2nd test that is declared in the file. It doesn't matter what it's called, or what it's testing (even an empty method) fails
  • If we put an Ignore attribute on the 2nd test then no tests fail
  • This only seems to happen in the "Optimised" instrumentation mode
  • MSTest doesn't have a problem running any of the tests
  • Renaming the test class has no effect
  • Un-nesting this test class from the partial class fixes the problem
  • Nesting the class within a different class also fixes the problem (in some scenarios)


My repro can be found here. If it works the same for you as it does for me, then Class2 will have a failing test in it (the first one). I've left some TODO comments in there showing what happens when certain things are changed.

Edited

Thanks for the repro. It looks to me like the optimised test discovery is somehow passing the wrong test method downstream. I'll see if I can get this fixed. I recommend switching to the Legacy instrumentation mode as a workaround for this assembly for now.
Would you be interested in trying the build below to see if this solves the issue for you?

NCrunch_Console_4.6.0.2.msi
NCrunch_Console_4.6.0.2.zip
NCrunch_GridNodeServer_4.6.0.2.msi
NCrunch_GridNodeServer_4.6.0.2.zip
NCrunch_LicenseServer_4.6.0.2.zip
NCrunch_VS2008_4.6.0.2.msi
NCrunch_VS2010_4.6.0.2.msi
NCrunch_VS2010_4.6.0.2.zip
NCrunch_VS2012_4.6.0.2.msi
NCrunch_VS2012_4.6.0.2.zip
NCrunch_VS2013_4.6.0.2.msi
NCrunch_VS2013_4.6.0.2.zip
NCrunch_VS2015_4.6.0.2.msi
NCrunch_VS2015_4.6.0.2.msi.7z
NCrunch_VS2015_4.6.0.2.zip
NCrunch_VS2017_4.6.0.2.msi
NCrunch_VS2017_4.6.0.2.msi.7z
NCrunch_VS2017_4.6.0.2.zip
NCrunch_VS2019_4.6.0.2.msi
NCrunch_VS2019_4.6.0.2.msi.7z
NCrunch_VS2019_4.6.0.2.zip
Hi Remco,

Sorry about the delay. For some reason I didn't get a notification about this post. Yes this fixes the issue for us. Thanks

Post a reply

Log in to reply.