一、程序要求

  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)的更多相关文章

  1. 软件测试技术(二)——使用等价类划分的方法进行的UI测试

    测试的目标程序 程序代码 import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File; impo ...

  2. 等价类划分方法的应用(jsp)

    [问题描述] 在三个文本框中输入字符串,要求均为1到6个英文字符或数字,按submit提交. [划分等价类] 条件1: 字符合法; 条件2: 输入1长度合法; 条件3: 输入2长度合法: 条件4: 输 ...

  3. Java上等价类划分测试的实现

    利用JavaFx实现对有效等价类和无效等价类的划分: 代码: import javafx.application.Application;import javafx.event.ActionEvent ...

  4. 黑盒测试用例设计方法&理论结合实际 -> 等价类划分

    一. 概念 等价类划分法是把程序的输入域划分成若干部分(子集),然后从每个部分中选取少数代表性数据作为测试用例.每一类的代表性数据在测试中的作用等价于这一类中的其他值. 二. 等价类划分的应用 等价类 ...

  5. 计算某天的下一天:黑盒测试之等价类划分+JUnit参数化测试

    题目要求 测试以下程序:该程序有三个输入变量month.day.year(month.day和year均为整数值,并且满足:1≤month≤12.1≤day≤31和1900≤year≤2050),分别 ...

  6. 软件测试技术(三)——使用因果图法进行的UI测试

    目标程序 较上次增加两个相同的输入框 使用方法介绍 因果图法 在Introduction to Software Testing by Paul一书中,将软件测试的覆盖标准划分为四类,logical ...

  7. [liu yanling]软件测试技巧

    1.添加.修改功能 (1)是否支持tab键 (2)是否支持enter键 (3)不符合要求的地方是否有错误提示 (4)保存后,是否也插入到数据库中 (5)字段唯一的,是否可以重复添加 (6)对编辑页列表 ...

  8. [liu yanling]规范软件测试流程

    测试计划 做任何事情都会有输入输出,对于测试过程我们可以把输入理解为测试计划.测试环境准备.测试工具的选择等等,输出可以理解为测试结果.测试用例设计即可以理解为以测试计划为输入的输出,也可以理解为以测 ...

  9. 软件测试software testing summarize

    软件测试(英语:software testing),描述一种用来促进鉴定软件的正确性.完整性.安全性和质量的过程.软件测试的经典定义是:在规定的条件下对程序进行操作,以发现程序错误,衡量软件质量,并对 ...

随机推荐

  1. Kolakoski数列

    2018-04-16 15:40:16 Kolakoski序列是一个仅由1和2组成的无限数列,是一种通过“自描述”来定义的数列.他在整数数列大全网站上排名第二位,足见该数列在组合数学界中的重要性. K ...

  2. <p>1、查询端口号占用,根据端口查看进程信息</p>

    2017年6月份的时候,我就着手在公司推广git,首先我自己尝试搭建了GitLab来管理代码,并且通过以下博客记录了GitLab的搭建,以及GitLab备份,GitLab升级等事情. git学习——& ...

  3. UVA-10816 Travel in Desert (最小瓶颈最短路)

    题目大意:给一张无向图,图中的每条边都有两个权值,长度d和热度r.找出从起点到终点的一条最大热度最小的路径,如果这样的路径有多条,选择一个最短的. 题目分析:如果只考虑最小的最大热度,那么本题就是一个 ...

  4. Leetcode 12

    //日积月累,水滴石穿class Solution { public: string longestCommonPrefix(vector<string>& strs) { if ...

  5. 017PHP基础知识——流程控制语句(五)

    <?php /** * break;退出循环: * 语法结构:break int;可以指定跳过几级循环: * while do_while for foreach switch */ /*$i= ...

  6. 201621123010《Java程序设计》第5周学习总结

    1. 本周学习总结 1.1 写出你认为本周学习中比较重要的知识点关键词 接口.面向接口编程 interface.implements has-a 关系 Comparable.Comparator 1. ...

  7. FIS 的思想和优点

    资源表 各种性能优化算法的加载框架 依赖声明有助于组件化 资源自动合并 链接 与webpack对比

  8. spring boot 教程(二)模板依赖

    在Spring boot中有一个很重要的概念,叫做约定优于配置--软件开发的简约原则.所以Spring boot会按照约定好的文件位置去找我们的包和类. 默认配置 Spring Boot默认提供静态资 ...

  9. Buildroot 打包文件系统流程跟踪

    /********************************************************************************* * Buildroot 打包文件系 ...

  10. ZetCode PyQt4 tutorial First programs

    #!/usr/bin/python # -*- coding: utf-8 -*- """ ZetCode PyQt4 tutorial In this example, ...