1

Windows Phone 7 アプリケーション開発で非同期関数呼び出しをテストできる単体テスト フレームワークを探していました。はい、私の目に飛び込んできたのはユニットドリブンでした。ただし、そのフレームワークは NUnit のように開発者にとって使いやすいものではありませんでした (残念ながら非同期メソッドをテストできません)。インターネットでは、人々はユニット テストに UD を使用しています。どなたか立ち寄ってアドバイスをいただけませんか?

私の具体的な質問は次のとおりです。

1) 次の初期化コードをどこに含めますか?

private void Application_Startup(object sender, StartupEventArgs e)
{
      this.RootVisual = new UnitDriven.TestEngine(Assembly.GetExecutingAssembly());
}

2) UD のテスト ケースを作成するにはどうすればよいですか? NUnit を使用すると、アプリケーションと共にテスト ケースを作成でき、NUnit は dll をロードしてテストを実行します。アプリケーションに入れようとしましたが、Visual Studio 2010 Express は常に、シンボル GetContext() が見つからないと文句を言います。

UnitTestContext context = GetContext();

3) UD には 3 つの dll が付属していました。UnitDrivenLight、UnitDrivenPhone、UnitDrivenNet... では、UnitDrivenLight と UnitDrivenPhone の役割は何ですか? 現時点では非常に混乱しています。

ありがとう

シモ

4

2 に答える 2

0

In the end, with Szalay's hints, I moved to use Microsoft's sliverlight test framework for asynchronous tests, here's the example test class:

namespace TestApp
{
    using System.Threading;
    using Microsoft.Silverlight.Testing;
    using Microsoft.VisualStudio.TestTools.UnitTesting;

    /// <summary>
    /// An example test class
    /// </summary>
    [TestClass]
    public class ExampleTestClass : SilverlightTest
    {

        /// <summary>
        /// Sample asynchronous test
        /// </summary>
        [TestMethod, Tag("Asynchronous Test"), Asynchronous]
        public void SampleAsynchronousTest()
        {
            ThreadPool.QueueUserWorkItem(o =>
                {
                    for (int j = 0; j < 10000; j++){}
                    CheckResult(10);
                });
        }

        /// <summary>
        /// Check result
        /// </summary>
        /// <param name="variable">result</param>
        private void CheckResult(int variable)
        {
            Assert.IsTrue(variable == 10);
            EnqueueTestComplete();
        }
    }
}
于 2011-11-03T11:26:24.797 に答える