软件测试——等价类划分(EditText * 3)
一、程序要求
EditBox 同时允许输入三个1到6个英文字符或数字,点击确定结束。
二、测试分析
| 编号 | 第一个输入框 | 第二个输入框 | 第三个输入框 | 输出 |
| 1 | null | null | null | 三个输入框均不符合要求 |
| 2 | abc | 123 | ab112 | 三个输入框均符合要求 |
| 3 | abc.. | 123 | ab112 | 第一个输入框不符合要求 |
| 4 | abc | 123.. | ab112 | 第二个输入框不符合要求 |
| 5 | abc | 123 | ab112. | 第三个输入框不符合要求 |
| 6 | abcadlsfkja | 123 | ab112 | 第一个输入框不符合要求 |
| 7 | abcadlsfkja | 12312192 | ab112 | 只有第三个输入框符合要求 |
| 8 | abcadlsfkja | 12312192 | ab112sfav | 三个输入框均不符合要求 |
三、程序代码
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 Equivalence extends Application{ public static void main(String arg0[]){
Equivalence.launch(arg0);
} @Override
public void start(Stage stage) throws Exception {
stage.setTitle("Equivalence class");
AnchorPane root = new AnchorPane(); Text message = new Text("请输入:");
root.getChildren().add(message);
AnchorPane.setTopAnchor(message, 50.0);
AnchorPane.setLeftAnchor(message, 80.0); final TextField textInput1 = new TextField();
root.getChildren().add(textInput1);
AnchorPane.setTopAnchor(textInput1, 70.0);
AnchorPane.setLeftAnchor(textInput1, 33.0); final TextField textInput2 = new TextField();
root.getChildren().add(textInput2);
AnchorPane.setTopAnchor(textInput2, 100.0);
AnchorPane.setLeftAnchor(textInput2, 33.0); final TextField textInput3 = new TextField();
root.getChildren().add(textInput3);
AnchorPane.setTopAnchor(textInput3, 130.0);
AnchorPane.setLeftAnchor(textInput3, 33.0); Button submit = new Button();
submit.setText("确定");
root.getChildren().add(submit);
AnchorPane.setTopAnchor(submit, 170.0);
AnchorPane.setLeftAnchor(submit, 77.0); submit.setOnAction(new EventHandler<ActionEvent>() {
public void handle(ActionEvent arg0) {
if(checkString(textInput1.getText().toString()) && checkString(textInput2.getText().toString()) && checkString(textInput3.getText().toString())){
Stage newStage = new Stage();
AnchorPane newRoot = new AnchorPane(); Text result = new Text("三个输入框均符合要求~");
newRoot.getChildren().add(result);
AnchorPane.setTopAnchor(result, 20.0);
AnchorPane.setLeftAnchor(result, 30.0); newStage.setScene(new Scene(newRoot, 200, 50));
newStage.show();
}else if(checkString(textInput1.getText().toString()) && checkString(textInput2.getText().toString())){
Stage newStage = new Stage();
AnchorPane newRoot = new AnchorPane(); Text result = new Text("第三个输入框不符合要求~");
newRoot.getChildren().add(result);
AnchorPane.setTopAnchor(result, 20.0);
AnchorPane.setLeftAnchor(result, 30.0); newStage.setScene(new Scene(newRoot, 200, 50));
newStage.show();
}else if(checkString(textInput1.getText().toString()) && checkString(textInput3.getText().toString())){
Stage newStage = new Stage();
AnchorPane newRoot = new AnchorPane(); Text result = new Text("第二个输入框不符合要求~");
newRoot.getChildren().add(result);
AnchorPane.setTopAnchor(result, 20.0);
AnchorPane.setLeftAnchor(result, 30.0); newStage.setScene(new Scene(newRoot, 200, 50));
newStage.show();
}else if(checkString(textInput2.getText().toString()) && checkString(textInput2.getText().toString())){
Stage newStage = new Stage();
AnchorPane newRoot = new AnchorPane(); Text result = new Text("第一个输入框不符合要求~");
newRoot.getChildren().add(result);
AnchorPane.setTopAnchor(result, 20.0);
AnchorPane.setLeftAnchor(result, 30.0); newStage.setScene(new Scene(newRoot, 200, 50));
newStage.show();
}else if(checkString(textInput1.getText().toString())){
Stage newStage = new Stage();
AnchorPane newRoot = new AnchorPane(); Text result = new Text("只有第一个输入框符合要求~");
newRoot.getChildren().add(result);
AnchorPane.setTopAnchor(result, 20.0);
AnchorPane.setLeftAnchor(result, 30.0); newStage.setScene(new Scene(newRoot, 200, 50));
newStage.show();
}else if(checkString(textInput2.getText().toString())){
Stage newStage = new Stage();
AnchorPane newRoot = new AnchorPane(); Text result = new Text("只有第二个输入框符合要求~");
newRoot.getChildren().add(result);
AnchorPane.setTopAnchor(result, 20.0);
AnchorPane.setLeftAnchor(result, 30.0); newStage.setScene(new Scene(newRoot, 200, 50));
newStage.show();
}else if(checkString(textInput3.getText().toString())){
Stage newStage = new Stage();
AnchorPane newRoot = new AnchorPane(); Text result = new Text("只有第三个输入框符合要求~");
newRoot.getChildren().add(result);
AnchorPane.setTopAnchor(result, 20.0);
AnchorPane.setLeftAnchor(result, 30.0); newStage.setScene(new Scene(newRoot, 200, 50));
newStage.show();
}else{
Stage newStage = new Stage();
AnchorPane newRoot = new AnchorPane(); Text result = new Text("三个输入框均不符合要求~");
newRoot.getChildren().add(result);
AnchorPane.setTopAnchor(result, 20.0);
AnchorPane.setLeftAnchor(result, 25.0); newStage.setScene(new Scene(newRoot, 200, 50));
newStage.show();
}
}
}); stage.setScene(new Scene(root, 200,230));
stage.show();
} public boolean checkString(String str){
if(str.length() == 0 || str.length() >= 7){
return false;
} char arr[] = new char[str.length()];
arr = str.toCharArray(); for(int i = 0; i < str.length(); i++){
if((arr[i] >= 'a' && arr[i] <= 'z')||(arr[i] >= 'A' && arr[i] <= 'Z')||(arr[i] >= '0' && arr[i] <= '9'));
else{
return false;
}
}
return true;
} }
四、程序结果








软件测试——等价类划分(EditText * 3)的更多相关文章
- 软件测试技术(二)——使用等价类划分的方法进行的UI测试
测试的目标程序 程序代码 import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File; impo ...
- 等价类划分方法的应用(jsp)
[问题描述] 在三个文本框中输入字符串,要求均为1到6个英文字符或数字,按submit提交. [划分等价类] 条件1: 字符合法; 条件2: 输入1长度合法; 条件3: 输入2长度合法: 条件4: 输 ...
- Java上等价类划分测试的实现
利用JavaFx实现对有效等价类和无效等价类的划分: 代码: import javafx.application.Application;import javafx.event.ActionEvent ...
- 黑盒测试用例设计方法&理论结合实际 -> 等价类划分
一. 概念 等价类划分法是把程序的输入域划分成若干部分(子集),然后从每个部分中选取少数代表性数据作为测试用例.每一类的代表性数据在测试中的作用等价于这一类中的其他值. 二. 等价类划分的应用 等价类 ...
- 计算某天的下一天:黑盒测试之等价类划分+JUnit参数化测试
题目要求 测试以下程序:该程序有三个输入变量month.day.year(month.day和year均为整数值,并且满足:1≤month≤12.1≤day≤31和1900≤year≤2050),分别 ...
- 软件测试技术(三)——使用因果图法进行的UI测试
目标程序 较上次增加两个相同的输入框 使用方法介绍 因果图法 在Introduction to Software Testing by Paul一书中,将软件测试的覆盖标准划分为四类,logical ...
- [liu yanling]软件测试技巧
1.添加.修改功能 (1)是否支持tab键 (2)是否支持enter键 (3)不符合要求的地方是否有错误提示 (4)保存后,是否也插入到数据库中 (5)字段唯一的,是否可以重复添加 (6)对编辑页列表 ...
- [liu yanling]规范软件测试流程
测试计划 做任何事情都会有输入输出,对于测试过程我们可以把输入理解为测试计划.测试环境准备.测试工具的选择等等,输出可以理解为测试结果.测试用例设计即可以理解为以测试计划为输入的输出,也可以理解为以测 ...
- 软件测试software testing summarize
软件测试(英语:software testing),描述一种用来促进鉴定软件的正确性.完整性.安全性和质量的过程.软件测试的经典定义是:在规定的条件下对程序进行操作,以发现程序错误,衡量软件质量,并对 ...
随机推荐
- 使用dos2unix批量转换文件
使用dos2unix批量转换文件 dos2unix是Linux下的一个用户转换格式的程序,由于windows上文件的结束符和linux上的不同,那么在windows上编写的文件或者是脚本在Linux上 ...
- Java实现GUI计算器【代码】
这几天用java写了一个计算器程序,开始写的时候原本只是想实现一下GUI(这个是直接读三个字母还是什么“固椅”的发音)界面,熟悉一下Java GUI 编程,为Java期末大作业练练手,本以为代码不会很 ...
- Arachni web扫描工具
扫描工具-Arachni from:https://blog.csdn.net/zixuanfy/article/details/52818527 ./arachni_console ...
- java垃圾回收期如何工作(编程思想)
垃圾回收器如何工作: 在以前的程序语言中,在堆上分配对象的代价十分昂贵,因此读者会自然觉得对Java中所有对象(基本类型除外)都在堆上分配的方式也非常高昂.然而,垃圾回收期对提高对象的创建速度,却具有 ...
- gson-2.2.api简单
使用gson的tojson和fromjson实现对象和json的转换 Gson gson = new Gson(); // Or use new GsonBuilder().create(); ...
- Centos安装Chrome浏览器失败解决办法
最近因为项目需要使用到Centos,自己经常使用Chrome,所有的书签以及信息都是同步在Google,所以尝试在Centos上安装Chrome,按照网上的资料都是安装失败,显示缺少资源,不过最终还是 ...
- SharePoint开发 - TimerJob简单实例讲解
博客地址 http://blog.csdn.net/foxdave SharePoint中的TimerJob类似于Windows系统的计划任务,可以实现定时执行指定操作的功能. 本篇所述的实例为在Sh ...
- 再谈Spring AOP
1.AOP的基本概念 在进行AOP开发前,先熟悉几个概念: 连接点(Jointpoint):表示需要在程序中插入横切关注点的扩展点,连接点可能是类初始化.方法执行.方法调用.字段调用或处理异常等等,S ...
- bzoj 4176 Lucas的数论
bzoj 4176 Lucas的数论 和约数个数和那题差不多.只不过那个题是多组询问,这题只询问一次,并且 \(n\) 开到了 \(10^9\). \[ \begin{align*} \sum_{i= ...
- vue-cli 本地开发mock数据使用方法
vue-cli 中可以通过配置 proxyTable 解决开发环境的跨域问题,具体可以参考这篇文章: Vue-cli proxyTable 解决开发环境的跨域问题 如果后端接口尚未开发完成,前端开发一 ...