Rickie的软件测试学习笔记-第三周

本次测试基于上次的对于单次输入合法性测试的修改,对多个输入的合法性同时测试

 

EDITBOX    文本框的非法输入测试:  允许1到6个英文字符或数字,按OK检测合法性并反馈。

 

                      

 

按限制条件或规则的等价类划分方法划分等价类                                                    

 

 

 有效等价类无效等价类
长度          1-6                 0,7, …  
  字符     A-Z,a-z,0-9      英文/数字以外字符,控制字符,标点符号

 

测试用例设计,根据有效和无效等价类可以设计出测试用例

 

编号

输入

预期输出

实际输出

Test1

null

输入含有非法字符

输入含有非法字符

Test2

1352468

字符长度大于6

字符长度大于6

Test3

./147

输入含有非法字符

输入含有非法字符

Test4

Cpp111

OK!

OK!

Test5

!@#$%

输入含有非法字符

输入含有非法字符

Test6

123$^&*

输入含有非法字符

输入含有非法字符

Test7

78%#%

输入含有非法字符

输入含有非法字符

Test8

asdadasd

字符长度大于6

字符长度大于6

Test9

aaaaa

OK!

OK!

Test10

123123

OK!

OK!

 

输出结果:

  

 

                                                     

 

                     

  

                   

 

EventHandler部分代码如下:

 1 btn1.addEventHandler(MouseEvent.MOUSE_CLICKED, new EventHandler<MouseEvent>(){
 2         public void handle(MouseEvent event){
 3             String textString1 = textfield1.getText().toString();
 4             wordTesting(textString1,text1);
 5             String textString2 = textfield2.getText().toString();
 6             wordTesting(textString2,text2);
 7             String textString3 = textfield3.getText().toString();
 8             wordTesting(textString3,text3);
 9         }
10     });
11     AnchorPane.setTopAnchor(hbox1, 40.0);
12     AnchorPane.setLeftAnchor(hbox1, 60.0);
13     AnchorPane.setTopAnchor(hbox2, 80.0);
14     AnchorPane.setLeftAnchor(hbox2, 60.0);
15     AnchorPane.setTopAnchor(hbox3, 120.0);
16     AnchorPane.setLeftAnchor(hbox3, 60.0);
17     AnchorPane.setTopAnchor(btn1, 180.0);
18     AnchorPane.setRightAnchor(btn1, 150.0);
19     root.getChildren().addAll(hbox1,hbox2,hbox3,btn1);
20     primaryStage.setScene(new Scene(root, 380, 250));
21     primaryStage.show();
22     }
23     private void wordTesting(String textString,Text textTesting)
24     {
25         char[] textChar = textString.toCharArray();
26         
27          if(textString.length()>6)
28             textTesting.setText("字符长度大于6");
29         else{
30             for(int i=0;i<textString.length();i++)
31             {
32                 if((textChar[i]>='0'&&textChar[i]<='9')||
33                    (textChar[i]>='a'&&textChar[i]<='z')||
34                    (textChar[i]>='A'&&textChar[i]<='Z'))
35                      textTesting.setText("OK!");
36                 else{
37                      textTesting.setText("输入含有非法字符");
38                      break;
39                 }
40             }
41         }
42 }

 

转载于:https://www.cnblogs.com/rickierao/p/4376059.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值