locked
Getting data for Unit Test from MTM VS 2012 RRS feed

  • Question

  • Working with C# on vs2012 and MTM with TFS.

    I have Unit tests that need to get data from MTM and eventually return results there.

    To get this to work in VS 2012 I have to make the test a CodedUI test. This means that the test will not run unless the desktop is open.

    Is there a way to do either of the following:

    1. Get unit tests as [TestClass]...[TestMethod] to run from MTM

    2. Get the test to Ignore the fact that the desktop is closed. Some registry setting or something? anything?

        In the future can there be an an Attribute for [CodedUITest] to ignore the fact that the desktop is locked.

    It would also be nice to be able to test for the desktop being locked as well.

    Cheers

    Monday, January 7, 2013 1:41 PM

Answers

  • Hello Kwisitive,

    Thank you for your post.

    I am not an expert of MTM, but as far as I know, you can run unit test from MTM. Using Microsoft Test Manager you can run manual tests, exploratory test sessions, and automated tests from a test plan.

    For more information, please see:

    Running Tests

    And Coded UI test is meant to exercise the user interface for an application. In other words, the application must be able to iterate with the desktop.  If you want to run Coded UI test, please don’t lock or have an active screen saver.

    In addition, if you have some issues which are related to MTM, I suggest that you can consult it directly on MTM forum(http://social.msdn.microsoft.com/Forums/en-US/vsmantest/threads) for better solution/support.

    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.


    • Edited by Amanda Zhu Tuesday, January 8, 2013 2:20 AM
    • Proposed as answer by Amanda Zhu Wednesday, January 9, 2013 7:22 AM
    • Marked as answer by Amanda Zhu Monday, January 14, 2013 1:52 AM
    Tuesday, January 8, 2013 2:19 AM
  • Ok ,so its not possible then and  needto raise it.

    I have done all the above and specifically want to use MTM and desk top closed as I stated.

    Cheers and thanks for the links tobugs and suggestions :)


    [Test automation, is there any other way?]

    • Marked as answer by Kwisitive Monday, January 14, 2013 5:40 PM
    Friday, January 11, 2013 8:02 PM

All replies

  • Hello Kwisitive,

    Thank you for your post.

    I am not an expert of MTM, but as far as I know, you can run unit test from MTM. Using Microsoft Test Manager you can run manual tests, exploratory test sessions, and automated tests from a test plan.

    For more information, please see:

    Running Tests

    And Coded UI test is meant to exercise the user interface for an application. In other words, the application must be able to iterate with the desktop.  If you want to run Coded UI test, please don’t lock or have an active screen saver.

    In addition, if you have some issues which are related to MTM, I suggest that you can consult it directly on MTM forum(http://social.msdn.microsoft.com/Forums/en-US/vsmantest/threads) for better solution/support.

    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.


    • Edited by Amanda Zhu Tuesday, January 8, 2013 2:20 AM
    • Proposed as answer by Amanda Zhu Wednesday, January 9, 2013 7:22 AM
    • Marked as answer by Amanda Zhu Monday, January 14, 2013 1:52 AM
    Tuesday, January 8, 2013 2:19 AM
  • Thanks for the reply but it does not help, unfortunatly.

    Yes any test can run with MTM data in its table but the method HAS to be Attributed with [CodedUITest], this means that I can not close the desktop.

    The fault lies with VS 2012 not being aable to do the same with [TestMethod].

    Where do I go to fault log this as it seems to be quite and omission.

    Cheers


    [Test automation, is there any other way?]

    Wednesday, January 9, 2013 5:10 PM
  • Hello Kwisitive,

    Glad to receive your reply.

    the method HAS to be Attributed with [CodedUITest],

    Do you mean that the attribute of coded UI test method in VS2012 has to be [CodedUITest]?

    No matter in VS2010 and VS2012, if you do coded UI testing, the attribute of the coded UI test class is [CodedUITest] and the attribute of Coded UI test method is [TestMethod].  If you do unit testing, the attribute of the unit test class is [TestClass] and the attribute of unit test method is [TestMethod].  

    You can create a new coded UI test and unit test to check the result.

    And if you do coded UI test, as I mentioned above, you must have an active desktop.

    If the attribute of Coded UI test method is [CodedUITest] in the CodedUITest.cs, I am afraid that there is something wrong with your VS. I suggest that you can try to repair it.

    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.

    Thursday, January 10, 2013 1:35 AM
  • Sorry, I do apologise. Im not making my self clear, I think.

    Try this...

    [CodedUITest] // << needs to be this else can not access MTM test data
    public class ATestClass       
    {
      [DataSource("Microsoft...", "httt://...", "12202", DataAccessMethod...), TestMethod]
      public void A_Test_Method()
      {
        ... some test code
      }
    }...

    I don't use any codedui stuff like interacting with the desktop of messing with UImaps or controls etc. I just and only use the TestContext.DataRow[""] to get the data from the MTM test case. So if there is another way to get this data without making the testClass a CodedUI test class, that would be great!

    To re-iterate then.

    What I want to do is a unit test not a codedUI test with the [TestClass] and [TestMethod] Attributes so I do NOT have to have my desktop open but still use data from an MTM test case.

    So my test uses data from an MTM test case to do a unit test not a codeduitest, currently this means that I have to have the test in class that has the attribute [CodedUITest]. (this means I have to have the desktop open)

    To currently have the desktop closed and locked I have to have a test in a class with the [TestClass] attribute.( This means that I can not use data from MTM)

    There is a conflict of what I want to do. I cannot do BOTH read data from MTM and have the desktop closed.

    I guess the prognosis is terminal :(

     Can you tell me where to go to report this as a bug/error/change/suggstion/plea or note for future amendment in VS 20XX. TA.


    [Test automation, is there any other way?]

    Thursday, January 10, 2013 2:33 PM
  • Hello Kwisitive,

    Glad to receive your reply.

    I am not an expert of MTM. I am not very sure about how you get data from a MTM test case in a Unit Test of VS and what data you define as a data source from MTM test case.

     Generally we can define a data source such as a csv file /Excel/SQL in the directory of the test project and bind it to unit test method. So I suggest that you can consult on MTM forum if you can set certain data as a data source and can be exported from MTM case and use in unit test.

    And as far as I know, if you are doing unit testing in Visual Studio, the attribute of the test class should be [TestClass] rather than [CodedUITest].

    As I mentioned above, if you do coded UI testing, the attribute of the coded UI test class is [CodedUITest] and the attribute of Coded UI test method is [TestMethod]. If you do unit testing, the attribute of the unit test class is [TestClass] and the attribute of unit test method is [TestMethod].

    According to the content in DataSource attribute, if you want to do data driven unit test, you can refer to the following article to make you have specified correct data source:

    How to: Create a data-driven unit test

    Also you can refer to the Data Source type and attribute provided in the following article which is also applied for unit test:

    How to: Create a Data-Driven Coded UI Test

    In addition, if you need to report a bug, you can redirect to this link: http://connect.microsoft.com/VisualStudio

    If you want to report some suggestion, you could submit this feature request:

    http://visualstudio.uservoice.com/forums/121579-visual-studio

    The Visual Studio product team is listening to user voice there. You can send your ideas/suggestions there and people can vote.

    Thanks for your understanding.

    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.

    • Proposed as answer by Amanda Zhu Saturday, January 12, 2013 10:41 PM
    • Marked as answer by Amanda Zhu Monday, January 14, 2013 1:51 AM
    • Unmarked as answer by Kwisitive Monday, January 14, 2013 5:39 PM
    Friday, January 11, 2013 2:19 AM
  • Ok ,so its not possible then and  needto raise it.

    I have done all the above and specifically want to use MTM and desk top closed as I stated.

    Cheers and thanks for the links tobugs and suggestions :)


    [Test automation, is there any other way?]

    • Marked as answer by Kwisitive Monday, January 14, 2013 5:40 PM
    Friday, January 11, 2013 8:02 PM
  • Hello Kwisitive,

    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.

    Monday, January 14, 2013 1:51 AM
  • No, your answer was unfortunatly not the answer to my question.

    Your answer is for a much more generic question about writing tests, avenues I persued in the first instance before comming here.

    Thank you for trying. Its now with Microsoft/Visual studio teams.

    Kwisitive.


    [Test automation, is there any other way?]

    Monday, January 14, 2013 5:42 PM
  • I think I have found the same problem.  It appears that the functionality was changed between VS2012/MTM2012 and VS2010/MTM2010.

    In VS2010 I could define a test like this:

     [TestClass]
        public class TestClass
        {
            [TestMethod]
            [DataSource("Microsoft.VisualStudio.TestTools.DataSource.TestCase",
                        "http://mytfsserver:8080/TFS;proj",
                        "1234",
                        DataAccessMethod.Sequential)]
            public void TestMethod()
            {

             }

       

    When I run this in VS2012 I get the following error:

    "Unable to find the requested .Net Framework Data Provider"

    If I replace  [TestClass] with [CodedUITest] then VS2012 will find the data source.  I have also noticed if I use mstest on the command line (vs2012) then it also works with the [TestClass] attribute.

    Tuesday, March 5, 2013 12:06 AM
  • Hello Kwisitive,

    Sorry for not helping you to resolve this issue.

    Its now with Microsoft/Visual studio teams.

    Have you resolved this issue though Microsoft/Visual Studio team’s help?

    After resolving it, you can share the solution here, which will be beneficial to other members with the similar issue.

    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.

    Tuesday, March 5, 2013 1:26 AM
  • Further investigation has shown that my issue is now resolved by creating a .testsettings file and making sure that it is in use (that is the check box next to it is checked).  There are no special settings in the file, it is just as created by VS2012.
    Tuesday, March 5, 2013 2:07 AM
  • So the only solution here is to create the .testsettings file?

    I don't want to do that.

    Any new info?

    Friday, August 16, 2013 7:47 PM
  • No, still the same problem with a code ui attributed test, doing a unit test and wanting to use data from mtm.

    [Test automation, is there any other way?]

    Saturday, August 17, 2013 3:31 AM