views:

123

answers:

2

I'm getting this error when generating a new unit test under Visual Studio 2010 using the context menu (right-click the method name -> "Generate Unit Tests"):

Private Accessor for methodName is not found. Please rebuild the containing project or run the Publicize.exe manually.

The method is public (checked that by applying applying a filter to not show non-public methods in the "Generate Unit Tests" dialog.

Visual Studio creates some kind of .accessor file automatically. Do I need to do anything in it?

What else could be the problem?

EDIT (more info that might be relevant)

  • I'm trying to test some classes inside a website project, although they don't do any webpage related stuff. They're just plain old C# classes.
  • All my class names are available inside the unit test class as ClassName_Accessor. And that causes the compiler to complain about the method signature not being correct.
A: 

The "accessor" is a class that works like one of the classes involved in your test, but the test method has access to its private and protected methods and fields. In particular, accessor classes are used for testing private and protected methods.

It sounds like there is a problem with the accessor, so you might want to try erasing and re-creating it. Rebuild the project. Then, right mouse click on your code and near where it says "Create Unit Tests", there should be another option that says "Create Private Accessor".

Rice Flour Cookies
I've done that "Create Private Accessor" thing, and it doesn't change a thing. And I shouldn't need to do it because all the classes and methods are public.Also, please check my edits, I'm guessing the fact that I can only access classes names ClassName_Accessor might have something to do with the problem.
Farinha
That's odd. I'm afraid I may not be of service, then... I don't know how you could have a problem if you're not calling non-public methods in the test code. Does the test project get created at all, or does the error prevent it?
Rice Flour Cookies
A: 

I have the same problem like described above. I use a ASP.NET Web Project and created a new Unit Test Project for a class of it.

I get the same error in german: "Der private-Accessor für TryPattern wurde nicht gefunden. Erstellen Sie das Projekt neu, das den Accessor enthält, oder führen Sie "Publicize.exe" manuell aus." means "Private Accessor for methodName is not found. Please rebuild the containing project or run the Publicize.exe manually."

IntelliSense is only showing me _Accessor Classes too, although i want to test public methods. But even these _Accessor Classes doens't work.

Are there any ideas?

dasheddot