Non public method for a test generating "Failed test"

Bug #1044438 reported by Cédric L. Charlier
This bug affects 1 person
Affects Status Importance Assigned to Milestone
NUnit Test Adapter
Won't Fix

Bug Description

If you've a protected/private method with the attribute [Test] on it and you're running the NUnit Test Adapter for Visual Studio, then this method is considered as a test and will fail with the error message "Method is not public". This is inconsistent with other NUnit runners which will ignore this method and not consider it as a Test (and s will not report a failed test).

Changed in nunit-vs-adapter:
status: New → Won't Fix
Revision history for this message
Charlie Poole (charlie.poole) wrote :

This is part of the behavior of NUnit, as designed.

A long time ago (around 2004 or so) NUnit simply ignored non-public methods marked with [Test]. The unfortunate result of this is that such tests never run but appear to have passed since no error message is shown. Clearly, when the user annotates a method with [Test], he is expressing the intention that the method should be treated as a test.

Faced with that problem, we decided to recognize _all_ methods with [Test] as tests, the ones with an acceptable signature are treated as valid, the rest as invalid. Currently, it's not true that "other NUnit runners" ignore such methods. Both the NUnit console runner and the Gui flag them as invalid methods, although it's easier to see with the Gui. In fact, the Gui now flags them as errors as soon as it loads the tests, before you even click run.

Long experience tells us that users don't like things that fail silently, so we try not to do it!


Revision history for this message
Cédric L. Charlier (seddryck) wrote :

Yes, indeed I was wrong. I was confused by Visual NUnit reporting such tests as "Green" (Well at least not "Red").

Thx for your answer.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.