• 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 }
  • 相关阅读:
    A
    B
    A
    A
    B
    C
    有趣的平方和的推导
    一篇写的非常好的匈牙利算法文章
    2014 UESTC Training for Data Structures G
    2014 UESTC Training for Data Structures H
  • 原文地址:https://www.cnblogs.com/rickierao/p/4376059.html
Copyright © 2020-2023  润新知