views:

226

answers:

5

Ok, dumb question. I'm trying to set up my first TypeMock demo project in VS2005 but it doesn't recognize the [TestMethod] attribute. I've included both the TypeMock and TypeMock.ArrangeActAssert assemblies and I'm referencing them with "using" statements. Even intellisense can't find the attribute. What am I doing wrong here?

+3  A: 

Which unit testing framework are you using? TestMethod sounds like the Visual Studio test system, while the NUnit counterpart is called Test.

Fredrik Mörk
+3  A: 

I'm guessing that the TestMethodAttribute comes from MSTest, not TypeMock. So you should add a reference to Microsoft.VisualStudio.QualityTools.UnitTestFramework

Edit: This is the namespace where the attribute is defined: Microsoft.VisualStudio.TestTools.UnitTesting;

Fredy Treboux
+2  A: 

[TestMethod] comes from the MSTest library not from the TypeMock framework

AutomatedTester
Ah, now I understand. I was of the impression that TypeMock functioned as a complete mock/unit test framework on its own. Thanks!
Repo Man
+1  A: 

Assuming you're using MSTest, you must include [TestClass()] for the class and [TestMethod()] for the tests (don't know if parenthesis are needed).

TypeMock is a mocking framework, so you should worry first for what testing framework you're using.

Samuel Carrijo
+1  A: 

[TestMethod] is from the Visual Studio unit testing 'framework'. The following code shows basically how to use the attribute:

    using Microsoft.VisualStudio.TestTools.UnitTesting;

[TestClass]
public class MyTests
{
 [TestMethod]
 public void MyFirstTest()
 {
  Assert.AreEqual(1, 1);
 }
}

If you're using NUnit or another framework, the attributes are possibily different.

Dennis van der Stelt