Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I've just manually done this:</p> <p>Created a new C# class library project with the following code:</p> <pre><code>namespace SO_Answer { public class Class1 { public void Test() { var k = "Hello"; } } } </code></pre> <p>Saved the project and then went to 'File->Add->New Project' and chose 'Test Project'. After VS created the unit test project, I added a reference to the class library project I created earlier.</p> <p>In my test I have this code:</p> <pre><code>namespace Unit_Test { /// &lt;summary&gt; /// Summary description for UnitTest1 /// &lt;/summary&gt; [TestClass] public class UnitTest1 { /// &lt;summary&gt; ///Gets or sets the test context which provides ///information about and functionality for the current test run. ///&lt;/summary&gt; public TestContext TestContext { get; set; } #region Additional test attributes // You can use the following additional attributes as you write your tests: // Use ClassInitialize to run code before running the first test in the class // [ClassInitialize()] // public static void MyClassInitialize(TestContext testContext) { } // Use ClassCleanup to run code after all tests in a class have run // [ClassCleanup()] // public static void MyClassCleanup() { } // Use TestInitialize to run code before running each test // [TestInitialize()] // public void MyTestInitialize() { } // Use TestCleanup to run code after each test has run // [TestCleanup()] // public void MyTestCleanup() { } #endregion /// &lt;summary&gt; /// The test method 1. /// &lt;/summary&gt; [TestMethod] public void TestMethod1() { var f = new Class1(); } } } </code></pre> <p>The only code I added was the a using statement and the <code>var f = new Class1();</code> statement. Looking at the MSTest runner, I can see <code>TestMethod1</code> appear.</p> <p>I can't think of a reason why your unit tests are not being picked up. The only time I've had this is because I was using the MSTest runner to try and view NUnit tests by mistake. Try starting from scratch.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload