标题: 用Mobile Test Framework进行自动化测试(二) [打印本页] 作者: flycat2008 时间: 2008-8-12 15:10 标题: 用Mobile Test Framework进行自动化测试(二) 在上一个小节中给大家简单介绍了WM6 SDK中带的Windows Mobile Test Framework。各位朋友可能对
Windows Mobile Test Framework有了一个大概的印象,但是对于怎么使用它还是有些疑惑。由于我的工
作比较繁忙,一直没有时间更新这个系列,对此很是抱歉。今天,我们就来用这个Windows Mobile Test
用记事本打开,它就是刚才的运行记录,内容比较长,我摘录其中几个部分如下:
................................................................
〈TESTCASE ID="0"〉
*** Test Name: Microsoft.MobileDevices.Tests.CalView.CalViewTests.CalViewBVT
*** Test ID: 0
BVT: BVT
Repro: -assembly Microsoft.MobileDevices.Tests.CalView.dll -suites CalViewTests -
tests CalViewBVT
Begin Step: CalViewBVT
[1] LaunchApplication(CalView, finder): Attempting to launch from start menu
[1] LaunchFromStartMenu(CalView, WindowFinder, False): Opening start menu
[1] OpenStartMenu(): Clicking on start menu to open it
[1] ClickStartMenu(): Clicking on start menu at (2, 2)
[1] ClickStartMenu(): Start menu successfully opened
[1] LaunchFromStartMenu(CalView, WindowFinder, False): Getting list of start menu
items
[1] LaunchFromStartMenu(CalView, WindowFinder, False): Item found - clicking on
index 9
[1] countBefore = 1
[1] countAfter = 2
[1] Verification = Pass: Count after is one greater
[1] ClickOK(): Clicking on task bar at (230, 10)
End Step : CalViewBVT
Verification = Pass: CalViewBVT
*** Result: Passed
〈/TESTCASE〉
................................................................
*** SUITE SUMMARY
***
*** Results
*** Passed: 1
*** Skipped: 0
*** Failed: 0
*** Aborted: 0
*** -------- ---------
*** Total: 1
〈/TESTGROUP〉
................................................................
4. 上面Log中的我标记出来的第一部分即是我们刚才跑的一条test case的运行记录;标记的后
CalViewTests.cs中可以找到如下代码,它就是这条case:
/// 〈summary〉
/// Add a description of the steps this test executes.
/// eg:
/// 1) Open Contact app
/// 2) Create a Contact
/// 3) Verify contact appeats in Main list view
/// 4) Close Contacts app
/// 〈/summary〉
/// 〈returns〉Log.LogResult.Pass on success〈/returns〉
[TestCaseAttribute("BVT", Type = TestType.BVT)]
public Log.LogResult CalViewBVT()
{
// Open the application
CalViewAreaLib.General.LaunchApp();
// Store and log the beginning count
int countBefore = CalViewAreaLib.MainDialog.GetItemCount();
Utils.GlobalLogger.AddComment("countBefore = {0}", countBefore.ToString());
// Select and copy one of the items
CalViewAreaLib.MainDialog.SelectItem(0);
CalViewAreaLib.MainDialog.CopySelectedItem();
// Store and log the count after copy
int countAfter = CalViewAreaLib.MainDialog.GetItemCount();
Utils.GlobalLogger.AddComment("countAfter = {0}", countAfter.ToString());
// Log a result based on the conditional that countAfter is one greater than
countBefore
Utils.GlobalLogResultManager.Results.Add("Count after is one greater", (countAfter
== (countBefore + 1)));
// Close the app to clean up
CalViewAreaLib.General.CloseApp();
// Results manager kept track of the result for you, return its summary
return Utils.GlobalLogResultManager.Results.Summary;
}