Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Test method must be public
MatthewSteeples
#1 Posted : Thursday, October 22, 2020 8:04:40 PM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 10/28/2014(UTC)
Posts: 116
Location: United Kingdom

Thanks: 7 times
Was thanked: 15 time(s) in 13 post(s)
We're receiving a failure for one of our tests, and the entire Trace Output of it is below:

Quote:
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.
Remco
#2 Posted : Thursday, October 22, 2020 11:38:09 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 6,201

Thanks: 807 times
Was thanked: 1065 time(s) in 1012 post(s)
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.
Remco
#3 Posted : Wednesday, November 18, 2020 3:18:07 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 6,201

Thanks: 807 times
Was thanked: 1065 time(s) in 1012 post(s)
MatthewSteeples
#4 Posted : Friday, November 27, 2020 5:14:58 PM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 10/28/2014(UTC)
Posts: 116
Location: United Kingdom

Thanks: 7 times
Was thanked: 15 time(s) in 13 post(s)
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
1 user thanked MatthewSteeples for this useful post.
Remco on 11/27/2020(UTC)
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

YAF | YAF © 2003-2011, Yet Another Forum.NET
This page was generated in 0.041 seconds.