1

そのため、Visual Studio 2010 とは対照的に、メソッドを右クリックしたときにコンテキスト メニューから [単体テストの作成] を使用できないことにも驚きました。

提案された回避策は、VS2010 で単体テストを作成し、それを VS2012 にインポートすることでした。

次に、この投稿http://dl.my/2013/enable-create-unit-tests-on-visual-studio-2012/を見つけました が、実際に機能しました!

しかし、メソッドの上で「単体テストの作成」をクリックすると、生成されたクラスには TestContext プロパティのみが含まれ、以前にウィザードで選択されたテスト メソッドは含まれません。

これは生成されたクラスです:

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

}

私は結果なしでウェブを検索しました..

ここで何が問題なのか誰か知っていますか?

4

1 に答える 1

1

どうやら、Windows Phone プロジェクトに「単体テストの生成...」ウィザードを使用することはできません。

ウィザードを使用しようとすると、次のエラーが表示されます。

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.

今できる最善の方法は、手動で作成することです。

于 2013-02-13T13:39:55.940 に答える