Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fixing the error: Creation of the private accessor for 'Microsoft.VisualStudio.TestTools.TypesAndSymbols.Assembly' failed

I'm creating unit tests for a Windows Forms application. One of my methods is an event-handler for a form (I don't know if this is the source of my problem):

private void ImportButton_Click(object sender, System.EventArgs e)
{
    // blah blah
}

Now when I attempt to create a unit test for this method via right-clicking the source -> "Create Unit Tests" everything seems to work fine until I open the generated unit test code:

/// <summary>
///A test for ImportButton_Click
///</summary>
[TestMethod()]
[DeploymentItem("FooBar.exe")]
public void ImportButton_ClickTest()
{
    // Creation of the private accessor for 'Microsoft.VisualStudio.TestTools.TypesAndSymbols.Assembly' failed
    Assert.Inconclusive("Creation of the private accessor for \'Microsoft.VisualStudio.TestTools.TypesAndSy" +
            "mbols.Assembly\' failed");
}

Any ideas how to fix this? I found this MSDN forum post that details the a similar issue which I don't think applies to my problem.

like image 419
Jeremy Avatar asked Oct 06 '09 10:10

Jeremy


3 Answers

Looks like this is a bug in VS2008 that they never bothered to resolve... :(

https://connect.microsoft.com/VisualStudio/feedback/details/365058

like image 165
demoncodemonkey Avatar answered Sep 28 '22 09:09

demoncodemonkey


This seems to be fixed more or less in VS2010 SP1, but the issue popped up again today. The assembly I was creating a test for contained covariant generic interfaces. The accessor builder didn't like that. Removing the "in" directives solved the problem and I could live with my interfaces not being covariant for the moment.

like image 31
Holstebroe Avatar answered Sep 28 '22 10:09

Holstebroe


I removed the Unit tests project, since, there were only couple of classes and added a new project with new set of files, and it worked. I was able to generate accessors for testing private methods too.

like image 20
Sandepku Avatar answered Sep 28 '22 08:09

Sandepku