WP7 应用程序测试中的单元测试日志 [英] Unit Testing Logs in WP7 application testing

查看:29
本文介绍了WP7 应用程序测试中的单元测试日志的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 Silverlight 单元测试框架来测试我的应用程序.单元测试框架成功执行并在手机应用程序页面中显示结果.我想将结果存储在设备内部的日志文件中,而不是将其显示在设备的电话应用程序页面上.请找到下图,其中显示了应用程序显示的结果

I m using Silverlight Unit Test framework for testing my application. The unit testing framework gets executed successfully and displays the result in the phone application page. I would like to get the results stored in a log file inside the device itself instead of displaying it on the phone application page on the device. Please find the image below which shows the results displayed for an application

http://www.jeff.wilcox.名称/wp-content/uploads/2010/03/SilverlightUnitTestFrameworkforWindowsPhone1_thumb.jpg

请建议是否有任何方法可以做到这一点.

Please suggest if there is any way to do it.

谢谢,木古

推荐答案

据我所知,结果不会存储在日志中,但您可以访问结果.

As far as I know the results are not stored in a log, but you can get access to the results.

从单元测试的 MainPage.xaml.cs 中,您可以挂接到 TestHarness 的 TestHarnessCompleted 事件以获取有关已完成测试运行的详细信息.然后,您可以根据需要格式化您的输出,并保存到 IndependentStorage 或/和从设备传输.

From within the unit test's MainPage.xaml.cs you can hook into the TestHarness's TestHarnessCompleted event to get details about the completed test run. You can then format your output as required, and save to IsolatedStorage or/and transfer off the device.

//inside MainPageLoad()
var unitTestSettings = UnitTestSystem.CreateDefaultSettings();
unitTestSettings.TestHarness.TestHarnessCompleted += TestRunCompletedCallback;
var testPage = UnitTestSystem.CreateTestPage(unitTestSettings) as IMobileTestPage;

void TestRunCompletedCallback(object sender, TestHarnessCompletedEventArgs e) {
    var testHarness = sender as UnitTestHarness;
    foreach (var result in testHarness.Results) {
        switch (result.Result) {
            case TestOutcome.Passed:
            case TestOutcome.Completed:
                break;
            default:
                // must be a failure of some kind
                // perform some outputting
                break;
         }
    }
}

我想我在某处读到可能有一些方法可以以编程方式将文件从隔离存储传输到桌面上.我将测试结果格式化为字符串,然后使用 NLog 将该输出发送到 监听服务 在我的桌面/构建服务器上运行.完整源 NLog 下载 提供了一个用于创建和运行此服务的 Visual Studio 示例项目.

I think I read somewhere that there may be ways of transferring files programmatically from IsolatedStorage onto your desktop. I instead format the test results to a String and then use NLog to send that output to a listening service running on my desktop/buildserver. The full source NLog download provides a Visual Studio sample project for creating and running this sevice.

干杯,艾尔.

这篇关于WP7 应用程序测试中的单元测试日志的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆