2014-09-24

测试自动化程序的任务
待测程序
测试程序
  启动待测程序
  设置窗体的属性
  获取窗体的属性
  设置控件的属性
  获取控件的属性
  方法调用
  测试程序代码

测试自动化程序的任务


 返回

基于反射的ui测试自动化程序,要完成的6项任务:

  • 通过某种方式从测试套件程序中运行待测程序(AUT: Applicaton Under Test),以便于两个程序之间进行通信
  • 操纵应用程序的窗体,从而模拟用户对窗体所实施的moving和resizing操作
  • 检查应用程序窗体,确定应用程序的状态是否准确
  • 操纵应用程序控件的属性,从而模拟用户的一些操作,比如模拟在一个TextBox控件里输入字符
  • 检查应用程序控件的属性,确定应用程序的状态是否准确
  • 调用应用程序的方法,从而模拟一些用户操作,比如模拟单击一个按钮

待测程序


 返回

AUT是一个剪刀、石头、布的猜拳软件,当点击button1时,会在listbox中显示谁是胜者。

《软件测试自动化之道》读书笔记 之 基于反射的UI测试

图1 待测程序GUI

AUT代码如下:

 1 using System;
 2 using System.Collections.Generic;
 3 using System.ComponentModel;
 4 using System.Data;
 5 using System.Drawing;
 6 using System.Linq;
 7 using System.Text;
 8 using System.Windows.Forms;
 9 
10 namespace AUT
11 {
12     public partial class Form1 : Form
13     {
14         public Form1()
15         {
16             InitializeComponent();
17         }
18 
19         private void button1_Click(object sender, EventArgs e)
20         {
21             string tb = textBox1.Text;
22             string cb = comboBox1.Text;
23 
24             if (tb == cb)
25                 listBox1.Items.Add("Result is a tie");
26             else if (tb == "paper" && cb == "rock" || tb == "rock" && cb == "scissors" || tb == "scissors" && cb == "paper")
27                 listBox1.Items.Add("The TextBox wins");
28             else
29                 listBox1.Items.Add("the ComboBox wins");
30         }
31 
32         private void Form1_Load(object sender, EventArgs e)
33         {
34             this.textBox1.Text = this.comboBox1.Items[1].ToString();
35             this.comboBox1.Text = this.comboBox1.Items[0].ToString();
36         }
37 
38         private void menuItem2_Click(object sender, EventArgs e)
39         {
40             this.Close();
41         }
42     }
43 }
View Code

相关文章:

  • 2021-08-02
  • 2022-12-23
  • 2022-01-03
  • 2021-08-25
  • 2021-07-27
  • 2021-06-22
  • 2022-12-23
猜你喜欢
  • 2021-05-23
  • 2021-05-15
  • 2021-08-24
  • 2021-08-19
  • 2022-01-29
  • 2021-08-15
  • 2021-06-04
相关资源
相似解决方案