Exception message: Microsoft.Moles.Framework.Moles.MoleInvalidOperationException: Moles requires tests to be an instrumented process

If you are new to Pex & moles like me, you may encounter this exception while mocking any property. I have mocked one of our Dictionary and received this exception. The cause is missing one attribute on the test method.

Resolution:

If you are in Visual Studio Unit test and using Pex & Moles, then use the attribute HostType for the method.

[TestMethod]

[HostType(“Moles”)]public void UnloadAfterDequeue04()

{ 

……………………………………………

}

Advertisements

About ambilykk

I am a Technology Evangelist on Microsoft Technologies. I am carrying the passion on Microsoft technologies specifically on web technologies such as ASP .Net and Ajax. My interests also include Azure and Visual Studio. Technology adoption and learning is my key strength and technology sharing is my passion.
This entry was posted in Pex and Moles and tagged , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s