zoukankan      html  css  js  c++  java
  • 软件测试——EditBox等价类划分扩展

    这篇博客是对上星期的EditBox的一个扩展。上周博客简单的列出EditBox的等价类划分与测试用例设计,此篇博客将一个EditBox扩展为三个EditBox。原理跟前面完全相同,下面直接上结果:

    等价类划分:

    有效等价类 无效等价类
    字符串a,b,c正确 a,b正确,c错误
      a,c正确,b错误
      b,c正确,a错误
      a,b错误,c正确
      a,c错误,b正确
      b,c错误,a正确
      a,b,c错误

    根据等价类,简单设计测试用例:

    a b c 结果
    a123456 a4 vv a长度应为1-6
    bOK
    cOK
    a2   df aOK
    b长度应为1-6
    cOK
        ss a长度应为1-6
    b长度应为1-6
    cOK

    下面是界面及代码:

    package editbox;


    import java.util.regex.Matcher;
    import java.util.regex.Pattern;
    import javafx.application.Application;
    import javafx.event.ActionEvent;
    import javafx.event.EventHandler;
    import javafx.scene.Scene;
    import javafx.scene.control.Button;
    import javafx.scene.control.TextField;
    import javafx.scene.layout.AnchorPane;
    import javafx.scene.text.Text;
    import javafx.stage.Stage;

    public class Editbox extends Application {
    public static boolean isRegularRptCode(String rptCode,String regEx) {
    Pattern p1 = Pattern.compile(regEx);
    Matcher m1 = p1.matcher(rptCode);
    boolean rs1 = m1.matches();
    return rs1;
    }
    public static void main(String[] args) {
    Editbox.launch(args);
    }
    public void start(Stage stage)throws Exception {
    stage.setTitle("editbox");
    AnchorPane root = new AnchorPane();
    Scene scene = new Scene(root, 400, 400);
    Text a= new Text("a");
    AnchorPane.setTopAnchor(a, 25.0);
    AnchorPane.setLeftAnchor(a, 50.0);
    Text b= new Text("b");
    AnchorPane.setTopAnchor(b, 75.0);
    AnchorPane.setLeftAnchor(b, 50.0);
    Text c= new Text("c");
    AnchorPane.setTopAnchor(c, 125.0);
    AnchorPane.setLeftAnchor(c, 50.0);
    final TextField tf=new TextField();
    AnchorPane.setTopAnchor(tf, 34.0);
    AnchorPane.setLeftAnchor(tf, 145.0);
    final TextField tf1=new TextField();
    AnchorPane.setTopAnchor(tf1, 84.0);
    AnchorPane.setLeftAnchor(tf1, 145.0);
    final TextField tf2=new TextField();
    AnchorPane.setTopAnchor(tf2, 134.0);
    AnchorPane.setLeftAnchor(tf2, 145.0);
    Button button = new Button("OK");
    AnchorPane.setTopAnchor(button, 134.0);
    AnchorPane.setLeftAnchor(button, 350.0);

    button.setOnAction( new EventHandler<ActionEvent>( ) {

    public void handle(ActionEvent actEvt) {
    final String name_ = tf.getText();
    final String name_1 = tf1.getText();
    final String name_2 = tf2.getText();
    if(name_.length()<1||name_.length()>6){
    System.out.println("a长度应为1-6");
    }
    else if(!isRegularRptCode(name_,"[a-z,A-Z,0-9]*")){
    System.out.println("a字符应为a-z,A-Z,0-9");
    }
    else{
    System.out.println("aOK");
    }
    if(name_1.length()<1||name_1.length()>6){
    System.out.println("b长度应为1-6");
    }
    else if(!isRegularRptCode(name_1,"[a-z,A-Z,0-9]*")){
    System.out.println("b字符应为a-z,A-Z,0-9");
    }
    else{
    System.out.println("bOK");
    }
    if(name_2.length()<1||name_2.length()>6){
    System.out.println("c长度应为1-6");
    }
    else if(!isRegularRptCode(name_2,"[a-z,A-Z,0-9]*")){
    System.out.println("c字符应为a-z,A-Z,0-9");
    }
    else{
    System.out.println("cOK");
    }
    }
    } );
    root.getChildren().addAll(a,b,c,tf,tf1,tf2,button);
    stage.setScene(scene);
    stage.show();
    } }

  • 相关阅读:
    SQL 强化练习 (七)
    SQL 强化练习 (六)
    SQL 强化练习 (五)
    SQL 强化练习 (四)
    典型相关分析 CCA
    SQL 强化练习(三)
    双向 和 多重 RNN
    SQL 强化练习 (二)
    SQL 强化练习 (一)
    SQL 查询强化
  • 原文地址:https://www.cnblogs.com/ericren/p/4376482.html
Copyright © 2011-2022 走看看