locked
Visual Studio 2012 does not run all the classes in a unit test class RRS feed

  • Question

  • Hi everyone,

    I am a beginner in c# programming and I'm working on a TDD app using Visual Studio 2012. Currently, I'm building test for other classes that were implemented. So I need to separate the test that are run from one class to another.

    I have tried to make separate classes file (by adding a new Unit Test), but Visual Studio 2012 will not run those tests. I have tried to paste them into the only file where tests are run and make 2 separate class using "TestClass" attributes for each classes, but with no avail.

    I have made a research here and found this:

    http://social.msdn.microsoft.com/Forums/en-US/winappswithcsharp/thread/b18bb39c-510f-4abe-9505-fde72481c7c8

    However even if all my classes / files reach the mentioned setup, the new tests I make will not run unless I group them into the original test class.

    How can I make Visual Studio 2012 run all the tests located in a test project?

    Tuesday, January 29, 2013 3:20 PM

All replies

  • Hello Herve,

    Thank you for your post.

    Do you mean that VS 2012 can’t run the new test methods in the new added unit test classes file?

    If yes, I would like to know if all tests including the new added unit test can be detected and displayed in Test Explorer after you build your solution/project.

    I suggest that you can reopen the VS, open the test project and then build your project to check if all test methods are displayed in Not Run Tests. If yes, then you can click Run All to check if all test methods can be run. If they can’t be run, if there are some errors after running, please provide us detailed error messages so that we can further look at this issue.

    If only new added test methods can’t appear in Test Explorer but the original test methods can, you try to check if all test methods are public and have [TestMethod] attribute. Make sure that your test classes are public otherwise they won't get discovered.

    Best regards,


    Amanda Zhu [MSFT]
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by Amanda Zhu Wednesday, February 6, 2013 10:00 AM
    • Unmarked as answer by Amanda Zhu Tuesday, August 13, 2013 1:20 AM
    Wednesday, January 30, 2013 2:37 AM
  • Hello Herve,

    I am marking my reply as answer. If my suggestion can’t help you, you can come back and unmark it as answer. If you have anything unclear, please feel free to come back and ask me.

    Best regards,


    Amanda Zhu [MSFT]
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Wednesday, February 6, 2013 10:01 AM
  • I have the same problem using MonoDroid TestRunner, whereas the [TestClass] tag of my second class gets added to the TestSuite, but all the tests are skipped.

    By the way Amanda Zhu, your accepted answer is not an answer at all and doesn't help! How dare you select your own answer as accepted... I believe you deeply misunderstood the sole purpose of this kind of website. Now the "unanswered" filter is completely useless since people that only answers to unanswered questions will never see this thread. I hope you are not doing that anywhere else <_< ...
    Friday, July 26, 2013 4:12 PM
  • I have the same problem. I have two files. They both start with 

    namespace UnitTests
    {
       [TestClass]
       public class StringExtensionsTests
       {
          [TestMethod]
          public void se_ToBooleanAndToBool()
          {
             String cInput1 = "True";
             String cInput2 = "no";
             String cInput3 = "yes";
             String cExpected = "TrueFalseTrue";
             String cResult = cInput1.ToBool().ToString() + cInput2.ToBoolean().ToString() + cInput3.ConvertToBoolean().ToString();
             Assert.IsTrue(cResult == cExpected);
          }

    and they used to work. Today I am trying 'Run All' and absolutely nothing happens. What should I do?

    Thanks.

    BTW, I agree with the comment - this is not an answer and should not be marked as such.


    For every expert, there is an equal and opposite expert. - Becker's Law


    My blog


    My TechNet articles

    Monday, August 12, 2013 9:43 PM
  • Hello Naomi,

    If you run the following assertion in unit test method instead of your unit test method, whether you can get the same issue?

    [TestMethod]

     public void TestMethod1()

            {

               

     String cExpected = "TruenoTrue";

               

    String cResult = "TrueFalseyes";

               

    Assert.IsTrue(cResult == cExpected);

               

            }

    I doubt your issue is related to your VS. I suggest that you can restart your PC, run VS as Admin, create two same test methods only with simple Assert statement and then run them with Run All in test explorer to check the result.

    If you get the same issue, I suggest that you try to repair your VS to check if it can help.

    Best regards,


    Amanda Zhu
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, August 13, 2013 5:09 AM
  • I eventually was able to resolve the problem. I cleared the PlayList (removed the only test that somehow stuck there) and finally was able to run all the tests. I hope this will stay correct now because it certainly was frustrating.

    For every expert, there is an equal and opposite expert. - Becker's Law


    My blog


    My TechNet articles

    Tuesday, August 13, 2013 2:07 PM