locked
Create Multiple tests from one project of CodedUI and execute all of them from one project. RRS feed

  • Question

  • Hi,

    I've created CodedUI Test Project. It's one project and i would like to add more than 200 test cases under this project. How to do it?

    Lets say for an example: I want to make automated tests for User account, Login creation and many more(up to 200 tests) them in a single CodedUI Test Project, so doing that i can execute them from one project these all multiplae test cases with one UIMap file. If so, how to do it.. is it possible? appreciate your help.

    Thank you.

    Tuesday, May 7, 2013 6:28 PM

Answers

  • You can add multiple Coded UI test cases in a similar way you are adding a single CodedUI test case.

    If you have already created one, say TC1() under CodedUITest.cs file, add one more method to the same CodedUITest class file, say TC2(), designate that method using [CodedUITest] attribute.

    Within the new method, TC2(), right click and record your actions.

    In a similarl way you can write more methods..

    For more details: http://msdn.microsoft.com/en-us/library/dd286726(VS.100).aspx (Look at the external sources, vidoes describing more details)

    ---

    You can very well execute all (can be from 1 to N) test  cases in a single project or all projects under one solution. You can choose any of the below ways in executing test cases.

    1. From VS, Press F5 or Ctrl + F5

    2. From VS, go to Test > Run > All Tests in Solution.

    4. Opening and selecting test cases to run through Test List editor or test view

    4. From Commandline,

    Open VS commandline.

    Go to the directory where the test DLL is present. Execute the below command:

    mstest.exe myAssembly.DLL

    For more details:http://msdn.microsoft.com/en-us/library/ms182486.aspx

    5. You can execute through Microsoft Test Manager (MTM), refer to the link below:

    http://msdn.microsoft.com/en-us/library/dd286680.aspx

    Important Note:

    If you are planning to automation 200 (huge number) of test cases and using a single UIMap file is absolutely not recommended as it involves lot of maintenance effort if you need to add/update any of the controls/actions recorded in that file.

    For more details: http://msdn.microsoft.com/en-us/library/ff398056(v=vs.100).aspx

    Coded UI Test best practises: http://msdn.microsoft.com/en-us/library/dd380782.aspx

    This would be pretty much easy (though it looks a little scattered, but this is all for a good design) 

    This link will give a comprehensive list of all details: http://blogs.msdn.com/b/mathew_aniyan/archive/2010/02/11/content-index-for-coded-ui-test.aspx

    Regards,


    Praveen


    • Edited by Praveen Pvs Tuesday, May 7, 2013 7:02 PM Added more details.
    • Marked as answer by vsautomation Tuesday, May 7, 2013 8:17 PM
    Tuesday, May 7, 2013 6:55 PM
  • It is easy to add test cases into an existing test class. Start by right clicking in the class and select the generate and record option (forget the precise name, do not have Visual Studion on this computer). Then record a new test case just as the first test was recorded. I recommend renaming the test case methods to be something meaningful, otherwise the test reports can be confusing.

    Before starting to record lots of new tests I recommend learning about multiple UI Maps. Putting everything in one UI Map file makes management very difficult. Recommendations for multiple UI Maps include one UI Map per (major) screen of the application, or one per testcase, or one per developer, or some mix of these.

    If you choose to have multiple UI Maps then do not do what I said in my first paragraph, do not right click in the source and select generate because it will record into the default UIMap.uitest file, not into the desired UI Map file.

    Regards

    Adrian

    • Marked as answer by vsautomation Tuesday, May 7, 2013 8:17 PM
    Tuesday, May 7, 2013 7:46 PM

All replies

  • You can add multiple Coded UI test cases in a similar way you are adding a single CodedUI test case.

    If you have already created one, say TC1() under CodedUITest.cs file, add one more method to the same CodedUITest class file, say TC2(), designate that method using [CodedUITest] attribute.

    Within the new method, TC2(), right click and record your actions.

    In a similarl way you can write more methods..

    For more details: http://msdn.microsoft.com/en-us/library/dd286726(VS.100).aspx (Look at the external sources, vidoes describing more details)

    ---

    You can very well execute all (can be from 1 to N) test  cases in a single project or all projects under one solution. You can choose any of the below ways in executing test cases.

    1. From VS, Press F5 or Ctrl + F5

    2. From VS, go to Test > Run > All Tests in Solution.

    4. Opening and selecting test cases to run through Test List editor or test view

    4. From Commandline,

    Open VS commandline.

    Go to the directory where the test DLL is present. Execute the below command:

    mstest.exe myAssembly.DLL

    For more details:http://msdn.microsoft.com/en-us/library/ms182486.aspx

    5. You can execute through Microsoft Test Manager (MTM), refer to the link below:

    http://msdn.microsoft.com/en-us/library/dd286680.aspx

    Important Note:

    If you are planning to automation 200 (huge number) of test cases and using a single UIMap file is absolutely not recommended as it involves lot of maintenance effort if you need to add/update any of the controls/actions recorded in that file.

    For more details: http://msdn.microsoft.com/en-us/library/ff398056(v=vs.100).aspx

    Coded UI Test best practises: http://msdn.microsoft.com/en-us/library/dd380782.aspx

    This would be pretty much easy (though it looks a little scattered, but this is all for a good design) 

    This link will give a comprehensive list of all details: http://blogs.msdn.com/b/mathew_aniyan/archive/2010/02/11/content-index-for-coded-ui-test.aspx

    Regards,


    Praveen


    • Edited by Praveen Pvs Tuesday, May 7, 2013 7:02 PM Added more details.
    • Marked as answer by vsautomation Tuesday, May 7, 2013 8:17 PM
    Tuesday, May 7, 2013 6:55 PM
  • It is easy to add test cases into an existing test class. Start by right clicking in the class and select the generate and record option (forget the precise name, do not have Visual Studion on this computer). Then record a new test case just as the first test was recorded. I recommend renaming the test case methods to be something meaningful, otherwise the test reports can be confusing.

    Before starting to record lots of new tests I recommend learning about multiple UI Maps. Putting everything in one UI Map file makes management very difficult. Recommendations for multiple UI Maps include one UI Map per (major) screen of the application, or one per testcase, or one per developer, or some mix of these.

    If you choose to have multiple UI Maps then do not do what I said in my first paragraph, do not right click in the source and select generate because it will record into the default UIMap.uitest file, not into the desired UI Map file.

    Regards

    Adrian

    • Marked as answer by vsautomation Tuesday, May 7, 2013 8:17 PM
    Tuesday, May 7, 2013 7:46 PM
  • Praveen,

    Thank you for your quick response, the infomration is very accurate and helpful. thanks for your support.

    Tuesday, May 7, 2013 8:15 PM
  • Adrain, thanks, i am going to try this as well.

    Tuesday, May 7, 2013 8:17 PM