| 网站首页 | 文章中心 | 电子书下载 | 矢量图库 | 视频教程 | 素材下载 | 程序代码下载 | JS代码 | 论坛 | 
常用软件类:
|杀毒安全 |联络聊天 |网络软件 |多媒体类 |系统工具 |图形图像 |系统工具 |应用软件 |行业软件
开发设计类:
|动画制作 |图像处理 |3D设计 |操作系统 |站长学院 |网络相关 |WEB设计 |数据库类 |程序开发
Windows Mobile程序的自动化测试
 

 

三、运行测试程序

 

1.  按下F5运行解决方案,注意请选择您已经启动好的那个模拟器。

2. 您会发现模拟器中系统自动打开运行了CalView这个程序。然后调用了其中的“copy”菜单项来复制了一个日历项目。最后退出程序。

3. 从模拟器中打开\test目录,您会发现一个results.log文件,将它从模拟器中copy到PC端,用记事本打开,它就是刚才的运行记录,内容比较长,我摘录其中几个部分如下:

................................................................

<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的运行记录;标记的后一段是该运行的整体情况,这次运行总共1条case,结果为pass。

5. 我们看到这条case的名称为Microsoft.MobileDevices.Tests.CalView.CalViewTests.CalViewBVT ,那么我们在tests工程的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; 

        }
        

 

从case的步骤我们可以看到/猜测,它先后打开CalView程序,然后选择其中第一个条目,然后复制一个。然后察看是否条目数量增加了一个。最后关闭程序再输出结果。在这里这些代码的含义您可以通过UAIL或者AreaLibrary的代码来查看具体含义,在后面我的Blog中也会陆续进一步介绍。

四、小结

从上面的演示我们看到我们可以很方便的通过我们的代码来模拟用户来操作我们的程序并进行验证。不错吧?

好了,就先介绍到这里吧.在下一节中,我们将会介绍一下Tests层代码的结构以及它的运作机制。

上一页  [1] [2] 


  • 上一篇文章:

  • 下一篇文章: 没有了
  • 相关文章