locked
Probably something very basic to solve - "No tests were run because no tests are loaded or the selected tests are disabled."

    Question

  • I am very new to Visual Studio, but I have used QTP before so presumed this would be similar in many aspects, although this does not seem to be the case from what I can see. Basically I have jumped right in to an existing team who are looking to introduce automated scripts in Visual Studio. I have done the below but I get the message “No tests were run because no tests are loaded or the selected tests are disabled.” In the bottom left when I try and run my recording. Anyone able to help?

     

    • Start Visual Studio 2010 Ultimate
    • Select ‘New Project’ from the ‘Start Page’
    • From the ‘New Project’ screen selected ‘Test’ and then ‘Test Project’
    • Hit the ‘OK’ button
    • On the ‘Connect to Team Project’ – connected to all the projects available to me
    • On the ‘Add Solution’ popup screen, just selected ‘OK’
    • The popup windows stop appearing, so presume it’s all setup. So I then right click on the Test Project’ that has been created on the ‘Solutions Explorer’ window and go to ‘Add’ >>> ‘Coded UI Test…’
    • On the ‘Generate Code for Coded UI Test’ I select the ‘OK’ button
    • I have already opened IE so I then click the ‘Record’ icon button and type ‘www.google.co.uk’.
    • I then pause the recording, followed by ‘Generate Code’ – click the ‘Add and Generate’ button.
    • Close the ‘UIMap – Coded UI Test Builder’ little window.

     

    I presume I am then done and just click save all, followed by clicking the ‘Run Tests in Current Context’ icon.

     

    The bottom left corner says ‘Build started…’ then it is followed with the message ‘No tests were run because no tests are loaded or the selected tests are disabled.’

     

    I must be missing something obvious? I have tried following the guides but I have found no solution so think perhaps it’s a setup thing that I a missing since this is our first time trying to create an automated script.

     

    Thanks in advance for any help with this, as it’s killing me not knowing why it wont just run what I have recorded.

    Thursday, September 08, 2011 9:44 AM

Answers

All replies

  • Hello Friend,

    Checkout following blog. I am sure it will help you.

    http://blogs.msdn.com/b/mathew_aniyan/archive/2010/02/11/content-index-for-coded-ui-test.aspx

    Thanks

    Paras

    Thursday, September 08, 2011 10:31 AM
  • Thanks Paras - I'll take a deeper look at the link, but I have already tried a few off that location so don't think I will find the solution there, but will look more throughly just in case. I even followed the below calculator example step by step but still got the "“No tests were run because no tests are loaded or the selected tests are disabled.” message when I tried to run the test. Any other ideas?

    http://blogs.msdn.com/b/mathew_aniyan/archive/2009/11/05/tutorial-coded-ui-test-beta2.aspx

    Thursday, September 08, 2011 10:41 AM
  • Ok, I think you should check CodedUITest.cs file in your project. Verify following kind of code is present there or not.
    [TestMethod]
    public void CodedUITestMethod()
    {
     this.UIMap.<Your Method Name>();
    }

    And take a look in test view (Test(menu)>>>Window>>>Test View) that your generated method is listed there or not.

    • Edited by Paras Chawla Thursday, September 08, 2011 11:22 AM
    Thursday, September 08, 2011 11:18 AM
  • Just skip some steps in your steps.Like ‘Connect to Team Project’ and ‘Add Solution’.

    •Start Visual Studio 2010 Ultimate
    •Select ‘New Project’ from the ‘Start Page’
    •From the ‘New Project’ screen selected ‘Test’ and then ‘Test Project’
    •Hit the ‘OK’ button
    •Then right click on the Test Project’ that has been created on the ‘Solutions Explorer’ window and go to ‘Add’ >>> ‘Coded UI Test…’
    •On the ‘Generate Code for Coded UI Test’ select the ‘OK’ button
    •If have already opened IE so then click the ‘Record’ icon button and type ‘www.google.co.uk’.
    •Then pause the recording, followed by ‘Generate Code’ – click the ‘Add and Generate’ button.
    •Close the ‘UIMap – Coded UI Test Builder’ little window.

    One thing plese verify befor playback that IE should be in same form or on same page as it was during recording.

    Thursday, September 08, 2011 11:32 AM
  • Thanks for the quick response Paras. I have got a Me.UIMap.<my method name>() in the Test Method block and when looking in the Test View their are no tests listed. I have tried a few times to try and get tests in it but can't seem to figure it out - I'd have thought it would have been an automatic process when the test is created.
    Thursday, September 08, 2011 11:35 AM
  • Ok try following code in Your CodedUITest.cs file. Change method name with your method name.

    using System;
    using System.Collections.Generic;
    using System.Text.RegularExpressions;
    using System.Windows.Input;
    using System.Windows.Forms;
    using System.Drawing;
    using Microsoft.VisualStudio.TestTools.UITesting;
    using Microsoft.VisualStudio.TestTools.UnitTesting;
    using Microsoft.VisualStudio.TestTools.UITest.Extension;
    using Keyboard = Microsoft.VisualStudio.TestTools.UITesting.Keyboard;


    namespace TestProject
    {
        /// <summary>
        /// Summary description for CodedUITest
        /// </summary>
        [CodedUITest]
        public class CodedUITest
        {
            public CodedUITest()
            {
            }

            [TestMethod]
            public void CodedUITestMethod()
            {
                this.UIMap.<Method Name>();
            }

     
     public TestContext TestContext
            {
                get
                {
                    return testContextInstance;
                }
                set
                {
                    testContextInstance = value;
                }
            }
            private TestContext testContextInstance;

            public UIMap UIMap
            {
                get
                {
                    if ((this.map == null))
                    {
                        this.map = new UIMap();
                    }

                    return this.map;
                }
            }

            private UIMap map;
        }
    }

    Thursday, September 08, 2011 11:48 AM
  • Thanks again Paras, I tried the above code, but it is still not running - and no errors in the error list to suggest any issues. My initial code was exactly the same as yours apart from the Test Project name and Test Method and even then they only had a number 26 at the end so almost exactly the same. The Test View still contains no tests. Any other ideas for a solution to this?

    Am I perhaps missing some sort of setting to tell it to run the tests locally or add them automatically after they are created?

    Thursday, September 08, 2011 12:16 PM
  • Hi , I am also running into the same issue .

    I have deleted all my tests in the Test View and now I want to add it again . how can i do it .  When I selected the Test View ,  it is displaying , below options . Create a New Test & Open existing tests.  I already have methods in my solution file and I want to add the existing one's . how can I do that ?

    Srini

     

    Thursday, September 08, 2011 8:52 PM
  • When I open my solution file , it is dispalying the test methods in test view and working fine now . but still I don't know how to add them after deleting .

     

    Thursday, September 08, 2011 9:07 PM
  • Srini,

    I did the same thing what u have done and observed that, deleting a test from test view causes to delete [TestMethod] attribute for that test.

    By adding [TestMethod] attribute again for that test u can see them in TestView.


    Thanks, Narasimha Please mark it as answer, if this reply answerd your question
    Friday, September 09, 2011 4:22 AM
  • Hi,

    open ur project. In solutionItems, u can find a file with extension ".vsmdi". open that file and select all loaded tests option that show on right side.

    Here u can find all ur tests.

    right click on the test and click on enable option

    now try to build and run ur test. try this and let me know if it works. 


    Thanks, Narasimha Please mark it as answer, if this reply answerd your question
    • Edited by Narasimha.Y Friday, September 09, 2011 4:38 AM
    Friday, September 09, 2011 4:38 AM
  • Hi Narasimha, I have attempted what you suggested with the ".vsmdi" file and I am unable to tick the 'All Loaded Tests' it along with the other two options seem to be disabled. As in I can see the checkbox but clicking it wont do anything.

    Any ideas on how to resolve this?

    Friday, September 09, 2011 8:51 AM
  • not need to check 'all loaded tests' check box, ...just select that one. After selecting that one u can see your test as shown in the below screenshot -

     

    Now right click on the test name, then a list of options will display. form those select 'enable' option

     

     


    Thanks, Narasimha Please mark it as answer, if this reply answerd your question
    • Proposed as answer by Paras Chawla Friday, September 09, 2011 9:26 AM
    Friday, September 09, 2011 9:15 AM
  • There are no tests showing Narasimha, even though I have just used the 'Coded UI Test Builder' to create one. I am following the below step by step but whenever I get to Step 19 and select Run Tests, I get the message in the bottom left of the screen saying "No tests were run because no tests are loaded or the selected tests are disabled". Their are no errors being shown and the build says it succeeded.

    http://blogs.msdn.com/b/mathew_aniyan/archive/2009/11/05/tutorial-coded-ui-test-beta2.aspx


    PS: I am missing the "UserControls.cs" in my list as mentioned in Step 18.b.iv as listed in the above link. Not sure if thats important or not.
    • Edited by HAH2012 Friday, September 09, 2011 9:47 AM
    Friday, September 09, 2011 9:32 AM
  • Record Coded UI test as mentioned in the above link and please share ur code with us.

    r u able to see ur test in 'Test View'?


    Thanks, Narasimha Please mark it as answer, if this reply answerd your question

    • Edited by Narasimha.Y Friday, September 09, 2011 10:05 AM
    Friday, September 09, 2011 9:48 AM
  • Narasimha, I have done as you asked and the code is below, I've also took screenshot of my Test View (which still contains no tests) and also the Solution Explorer which is still missing the "UserControls.cs" as mentioned in Step 18.b.iv

    using System;
    using System.Collections.Generic;
    using System.Text.RegularExpressions;
    using System.Windows.Input;
    using System.Windows.Forms;
    using System.Drawing;
    using Microsoft.VisualStudio.TestTools.UITesting;
    using Microsoft.VisualStudio.TestTools.UnitTesting;
    using Microsoft.VisualStudio.TestTools.UITest.Extension;
    using Keyboard = Microsoft.VisualStudio.TestTools.UITesting.Keyboard;


    namespace TutorialProject3
    {
        /// <summary>
        /// Summary description for CodedUITest1
        /// </summary>
        [CodedUITest]
        public class CodedUITest1
        {
            public CodedUITest1()
            {
            }

            [TestMethod]
            public void CodedUITestMethod1()
            {
                // To generate code for this test, select "Generate Code for Coded UI Test" from the shortcut menu and select one of the menu items.
                // For more information on generated code, see http://go.microsoft.com/fwlink/?LinkId=179463
                this.UIMap.TestAdd();
                this.UIMap.AssertSum();
            }

            #region Additional test attributes

            // You can use the following additional attributes as you write your tests:

            ////Use TestInitialize to run code before running each test
            //[TestInitialize()]
            //public void MyTestInitialize()
            //{       
            //    // To generate code for this test, select "Generate Code for Coded UI Test" from the shortcut menu and select one of the menu items.
            //    // For more information on generated code, see http://go.microsoft.com/fwlink/?LinkId=179463
            //}

            ////Use TestCleanup to run code after each test has run
            //[TestCleanup()]
            //public void MyTestCleanup()
            //{       
            //    // To generate code for this test, select "Generate Code for Coded UI Test" from the shortcut menu and select one of the menu items.
            //    // For more information on generated code, see http://go.microsoft.com/fwlink/?LinkId=179463
            //}

            #endregion

            /// <summary>
            ///Gets or sets the test context which provides
            ///information about and functionality for the current test run.
            ///</summary>
            public TestContext TestContext
            {
                get
                {
                    return testContextInstance;
                }
                set
                {
                    testContextInstance = value;
                }
            }
            private TestContext testContextInstance;

            public UIMap UIMap
            {
                get
                {
                    if ((this.map == null))
                    {
                        this.map = new UIMap();
                    }

                    return this.map;
                }
            }

            private UIMap map;
        }
    }

    Friday, September 09, 2011 10:28 AM
  • Have you tried to click on refresh button in test view. What happening in your machine after clicking on refresh bitton in test view.
    Friday, September 09, 2011 10:36 AM
  • Hi Paras, I have clicked 'Refersh' on the 'Test View' window and the 'Output' window says "Build: 1 succeeded or up-to-date, 0 failed, 0 skipped" but the 'Test View' window still shows the yellow bar message "Changes were made to the tests, click Refresh to update; Item(s) selected: 0"

    It's as if it knows I have created a test but at the same time can't "see" it.

    Friday, September 09, 2011 10:57 AM
  • Have a look at the following links...i don't know how much they'll help u.

    http://stackoverflow.com/questions/3983558/visual-studio-2010-no-tests-were-run-because-no-tests-are-loaded-or-the-selecte

    http://social.msdn.microsoft.com/Forums/en-ZA/vstswebtest/thread/1e055fb1-93cb-4ac9-ac60-5cab84f5873e

    and the final thing u can do is re installing the Visual studio.


    Thanks, Narasimha Please mark it as answer, if this reply answerd your question
    Friday, September 09, 2011 11:07 AM
  • Please verify that there is a bin folder present in your Project folder or not? If its not there then create it and then again compile. Like as following path

    C:\Documents and Settings\paras\My Documents\Visual Studio 2010\Projects\TestProject\TestProject\bin

    And also Take a look into following link:

    http://richallen.blogspot.com/2008/05/ms-test-re-enabling-ignored-tests.html

    Thanks




    Friday, September 09, 2011 11:50 AM
  • Also try:

    Tools > Options > Test Tools > Test Project and unchecked "Disable background discovery of test methods".

    It worked re-opening the solution but not doing a full clean and rebuild.

    • Proposed as answer by marvin bland Thursday, September 15, 2011 4:31 PM
    Friday, September 09, 2011 12:04 PM