简体   繁体   中英

Visual Studio 2012 auto create unit test - WP8 application

So, I was also surprised that the "create unit test" is not available from the context menu when right clicking over a method, as opposed to Visual Studio 2010.

The work arounds suggested was to create the unit tests in VS2010 and then import it back to VS2012.

Then i found this post http://dl.my/2013/enable-create-unit-tests-on-visual-studio-2012/ and that indeed worked!

But now, after i click the "create unit test" over a method, the generated class only contains a TestContext property, without the test methods that was chosed in the wizard previously.

This is the generated class:

/// <summary>
///This is a test class for XXXTest and is intended
///to contain all XXXTest Unit Tests
///</summary>
[TestClass()]
public class XXXTest
{


    private TestContext testContextInstance;

    /// <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;
        }
    }

    #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

}

I have searched the web with no results..

Does anybody know what's the issue here?

Apparently, it is not possible to use "Generate Unit Tests..." wizard for Windows Phone projects.

As you try to use the wizard, the following error will be prompted:

While trying to generate your tests, the following errors occurred:
You can only add WinMD references to a project targeting Windows 8.0 or higher. To learn how to retarget your project to a different version of Windows, please see the 'Core subgroup' section underneath the 'Windows tab' section in the 'How to: add or remove references by using the Reference Manager' help page: http://msdn.microsoft.com/library/hh708954(v=vs.110).aspx.

The best you can do now is by creating it manually.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM