• 软件测试之等价划分二


    上周通过测试用例实现等价划分,这次需要三个输入框同时输入。其实只是增加了测试的次数。

    这次我用java的程序测试。

    首先是无输入:

    会提示你输入字符必须是1-6.

    测试1:

    字符一:

    121221f

    字符二:

    jjhj12

    字符三:

    dsd1&&

    测试结果如下:

    测试2:

    字符一:

    1212fd

    字符二:

    fdf123

    字符三:

    Adf2d1

    测试结果:

    java代码如下:

    package ceshi;
    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 softCeshi extends Application{
    public static boolean isRegularRptCode(String rptCode,String regEx) {
    Pattern pat = Pattern.compile(regEx);
    Matcher mat = pat.matcher(rptCode);
    boolean rs = mat.matches();
    return rs;
    }
    public static void main(String[ ] args) {
    softCeshi.launch( args );
    }
    public void start( Stage Stage ) {
    Stage.setTitle( "软件测试用例" );
    final AnchorPane anchorPane = new AnchorPane();
    Stage.setScene(new Scene(anchorPane, 400, 400));

    Text test1= new Text("字符一");
    Text test2= new Text("字符二");
    Text test3= new Text("字符三");

    final TextField []text = new TextField[3];

    text[0] = new TextField();
    text[1] = new TextField();
    text[2] = new TextField();

    Button btn = new Button( );
    btn.setText("提交");

    AnchorPane.setTopAnchor(test1, 50.0);
    AnchorPane.setLeftAnchor(test1, 60.0);

    AnchorPane.setTopAnchor(test2, 100.0);
    AnchorPane.setLeftAnchor(test2, 60.0);

    AnchorPane.setTopAnchor(test3, 150.0);
    AnchorPane.setLeftAnchor(test3, 60.0);

    AnchorPane.setTopAnchor(text[0], 50.0);
    AnchorPane.setLeftAnchor(text[0], 120.0);

    AnchorPane.setTopAnchor(text[1], 100.0);
    AnchorPane.setLeftAnchor(text[1], 120.0);

    AnchorPane.setTopAnchor(text[2], 150.0);
    AnchorPane.setLeftAnchor(text[2], 120.0);

    AnchorPane.setTopAnchor(btn, 150.0);
    AnchorPane.setLeftAnchor(btn, 300.0);

    btn.setOnAction( new EventHandler<ActionEvent>( ) {
    public void handle(ActionEvent actEvt) {
    final String []test = new String[3];
    for(int i=0;i<3;i++){
    test[i] = text[i].getText();
    if(test[i].length()<1||test[i].length()>6){
    TextField text1 = new TextField("输入长度应为1-6");
    AnchorPane.setTopAnchor(text1, 200.0+i*50);
    AnchorPane.setLeftAnchor(text1, 120.0);
    anchorPane.getChildren().add(text1);
    }
    else if(!isRegularRptCode(test[i],"[a-z,A-Z,0-9]*")){
    TextField text2 = new TextField("输入字符应为a-z,A-Z,0-9");
    AnchorPane.setTopAnchor(text2, 200.0+i*50);
    AnchorPane.setLeftAnchor(text2, 120.0);
    anchorPane.getChildren().add(text2);

    }
    else{
    TextField text3 = new TextField("输入正确");
    AnchorPane.setTopAnchor(text3, 200.0+i*50);
    AnchorPane.setLeftAnchor(text3, 120.0);
    anchorPane.getChildren().add(text3);
    }
    }
    }} );

    anchorPane.getChildren().addAll(btn,test1,test2,test3,text[0],text[1],text[2]);
    Stage.show( );
    }
    }

  • 相关阅读:
    Tomcat9报错 The valid characters are defined in RFC 7230 and RFC 3986
    Job for ssh.service failed because the control process exited with error code.......
    解决 ora-28001 密码过期的处理办法
    Vmware unknow Interface ens33
    ubuntu桌面环境安装中文环境
    (CRON) info (No MTA installed, discarding output)” error in the syslog
    SSH Secure Shell链接Ubuntu报错Server responded "Algorithm negotiation failed"
    mysql备份数据库出错mysqldump: [ERROR] unknown option '--no-beep'
    dclcommon200.bpl
    字节 汉字判断
  • 原文地址:https://www.cnblogs.com/li1002/p/4375879.html
Copyright © 2020-2023  润新知