软件测试——等价类划分(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),描述一种用来促进鉴定软件的正确性.完整性.安全性和质量的过程.软件测试的经典定义是:在规定的条件下对程序进行操作,以发现程序错误,衡量软件质量,并对 ...
随机推荐
- oracle10g连接自动断开,报ORA-03135错误
问题描述: oracle使用过一段时间,连接断开,报ORA-03135错误. 问题挖掘: 用pl/sql和sqlplus连接oracle,也存在该问题,确定该问题与连接方式无关. 查看服务器,发现没有 ...
- docker容器互联 (.net core容器,mysql容器)
背景 有两个容器一个运行的.net core的项目 另一个运行的mysql的数据 并且这两个容器在同一个机子上(或者局域网),那么理论上.net core的项目去访问mysql是可以走内网的 但是容器 ...
- Android------个人项目(歆语气象通)
歆语气象通: 歆语气象伴随你的身边,便捷生活. 包含了以下功能: 1. 天气预报数据覆盖中国城市和地区:2. 提供一周天气预报及最低最高温度,时刻关注天气,轻松计划出行:3. 各种指数详细信息,如太阳 ...
- 【hive】count() count(if) count(distinct if) sum(if)的区别
表名: user_active_day (用户日活表) 表内容: user_id(用户id) user_is_new(是否新用户 1:新增用户 0:老用户) location_city(用户所在地 ...
- BZOJ3707 圈地
只会O(n ^ 3)路过= = OrzOrzOrzOrzOrz "出题人题解: 显然,这时候暴力枚举会T.于是我们转变一下思路,如果我们确定了2个点以后,第三个点有必要去盲目的枚举吗?答案是 ...
- 毒害一代Java程序猿的HttpClient
前言 2016年以来,越来越多Android开发者使用Retrofit作为HTTP请求框架.原因其一,Google发布Android 6.0 SDK (API 23) 抛弃了HttpClient:其二 ...
- tensorflow :ckpt模型转换为pytorch : hdf5模型
参考链接:https://github.com/bermanmaxim/jaccardSegment/blob/master/ckpt_to_dd.py import tensorflow as tf ...
- 斯特灵(Stirling)数
http://zh.wikipedia.org/wiki/%E6%96%AF%E7%89%B9%E7%81%B5%E6%95%B0 第一类:n个元素分成k个非空循环排列(环)的方法总数 递推式:s(n ...
- Linux运维学习笔记-通配符及正则表达式知识总结
通配符: * 代表所有 ? 任意一个字符 : 两个命令的分隔符 # 注释 | 管道,将|前命令的执行结果作为|后命令的输入 ~ 用户的家目录 - 上一次的目录 $ 变量前面 ...
- 转 关于nvcc fatal : Value 'sm_20' is not defined for option 'gpu-architecture'的问题
原文地址: https://blog.csdn.net/Mao_Jonah/article/details/78965827 关于nvcc fatal : Value ‘sm_20’ is not d ...