软件测试——等价类划分(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),描述一种用来促进鉴定软件的正确性.完整性.安全性和质量的过程.软件测试的经典定义是:在规定的条件下对程序进行操作,以发现程序错误,衡量软件质量,并对 ...
随机推荐
- Java字符串分割(转)
java.lang.String 的 split() 方法, JDK 1.4 or later public String[] split(String regex,int limit) 示例代码 p ...
- [转]VS2015编译的程序在其他机器上缺少msvcp120.dll
http://www.lai18.com/content/1159618.html 1. 今天分享一个自己在开发过程中遇到的困难. 用VS2015开发了一个windows客户端(win32项目),在自 ...
- Linux下,EPM11.1.1.3 configurator 不能启动AdminServer
需要测试环境, 安装EPM11.1.1.3 到 CentOS 5.6 在运行configurator(/app/hyperion/common/config/9.5.0.0 时, 卡在[Startin ...
- 雷林鹏分享:Ruby 异常
Ruby 异常 异常和执行总是被联系在一起.如果您打开一个不存在的文件,且没有恰当地处理这种情况,那么您的程序则被认为是低质量的. 如果异常发生,则程序停止.异常用于处理各种类型的错误,这些错误可能在 ...
- JS级联下拉框
//Ajax级联获取SDKfunction GetDropDownList(parent_ddlID, fill_dllID, url, param) { this.pId = parent_d ...
- rails5.2新特性--ActiveStorage, 使用80percent/rails-template
看guide,看ruby-China的好贴,看最新版的书上案例. 以下摘自https://ruby-china.org/topics/36666 作者lyfi2003 用户对上传文件的要求体验: 上传 ...
- hdu 5696 区间的价值
套路题 求出来以每个数为最大值/最小值时的一个区间范围, 然后枚举每个数为最大值的情况更新即可, 但是对于重复数的话需要特判一下, 假如用map记录来特判复杂度就是$O(nlogn)$, 不过题目说了 ...
- CentOS下安装docker,docker-compose
1.查看系统发行版本: lsb_release -a 2.安装docker:Docker 是一个开源的应用容器引擎,可以让开发者打包他们的应用以及依赖包到一个轻量级.可移植的容器中,然后发布到任何流行 ...
- UVA-1515 Pool construction (最小割)
题目大意:有一块地,分成nxm块.有的块上长着草,有的块上是荒地.将任何一块长着草的块上的草拔掉都需要花费d个力气,往任何一块荒地上种上草都需要花费f个力气,在草和荒地之间架一个篱笆需要花费b个力气, ...
- 【hive】时间段为五分钟的统计
问题内容 今天遇到了一个需求,需求就是时间段为5分钟的统计.有数据的时间戳.对成交单量进行统计. 想法思路 因为数据有时间戳,可以通过from_unixtime()来获取具体的时间. 有了具体的时间, ...