Java上等价类划分测试的实现
利用JavaFx实现对有效等价类和无效等价类的划分:
代码:
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.Label;
import javafx.scene.control.TextField;
import javafx.scene.layout.AnchorPane;
import javafx.scene.text.Font;
import javafx.scene.text.FontWeight;
import javafx.scene.text.Text;
import javafx.stage.Stage;
public class Main extends Application{
TextField textField;
Label label;
public static void main(String[] args) {
Application.launch(args);
}
public void start(Stage stage){
stage.setTitle("For Test");
AnchorPane root = new AnchorPane();
Scene scene = new Scene(root, 500, 300);
Text text = new Text();
text.setText("Write something for test:");
text.setFont(Font.font("Comic Sans MS", 18));
AnchorPane.setTopAnchor(text, 0.0);
AnchorPane.setLeftAnchor(text, 10.0);
Text text2 = new Text();
text2.setText("Result:");
text2.setFont(Font.font("Comic Sans MS", 18));
AnchorPane.setTopAnchor(text2, 50.0);
AnchorPane.setLeftAnchor(text2, 10.0);
label = new Label(" ");
label.setFont(Font.font ("Comic Sans MS", 16));
AnchorPane.setTopAnchor(label, 90.0);
AnchorPane.setLeftAnchor(label, 50.0);
Button button = new Button();
button.setText(" Sure ");
AnchorPane.setTopAnchor(button, 5.0);
AnchorPane.setLeftAnchor(button, 420.0);
textField = new TextField ();
textField.setPrefWidth(160);
textField.getText();
AnchorPane.setTopAnchor(textField, 5.0);
AnchorPane.setLeftAnchor(textField, 250.0);
button.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent e) {
char input[] = textField.getText().toCharArray();
int errorcase = 3;
if (textField.getText().length()==0 || textField.getText().length() >= 7) {
errorcase = 1;
}
else {
for(int i=0;i<textField.getText().length();i++){
if(!((input[i]>=48 && input[i]<57) || (input[i]>=65 && input[i]<=90) || (input[i]>=97 && input[i]<=122))){
errorcase = 2;
break;
}
}
}
switch(errorcase){
case 1:
label.setText("Input is " + textField.getText() + "\n" + "Error1: The length of input is error");
break;
case 2:
label.setText("Input is " + textField.getText() + "\n" + "Error2: The kind of input is error");
break;
case 3:
label.setText("Input is " + textField.getText() + "\n" + "Succeed: Input is correct");
}
}
});
root.getChildren().addAll(text,text2,textField,button,label);
stage.setResizable(false);
stage.setScene(scene);
stage.show();
}
}
等价类划分和测试用例设计:

编号1、2、3、8、11、17的测试截图:






Java上等价类划分测试的实现的更多相关文章
- 计算某天的下一天:黑盒测试之等价类划分+JUnit参数化测试
题目要求 测试以下程序:该程序有三个输入变量month.day.year(month.day和year均为整数值,并且满足:1≤month≤12.1≤day≤31和1900≤year≤2050),分别 ...
- 软件测试技术(二)——使用等价类划分的方法进行的UI测试
测试的目标程序 程序代码 import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File; impo ...
- 深入浅出解读 Java 虚拟机的差别测试技术
本文分享基于字节码种子生成有效.可执行的字节码文件变种,并用于 JVM 实现的差别测试.本文特别提出用于修改字节码语法的classfuzz技术和修改字节码语义的classming技术.上述变种技术系统 ...
- 等价类划分方法的应用(jsp)
[问题描述] 在三个文本框中输入字符串,要求均为1到6个英文字符或数字,按submit提交. [划分等价类] 条件1: 字符合法; 条件2: 输入1长度合法; 条件3: 输入2长度合法: 条件4: 输 ...
- Java 内存区域划分
JVM的内存区域划分 学过C语言的朋友都知道C编译器在划分内存区域的时候经常将管理的区域划分为数据段和代码段,数据段包括堆.栈以及静态数据区.那么在Java语言当中,内存又是如何划分的 ...
- edtftpj让Java上传FTP文件支持断点续传
在用Java实现FTP上传文件功能时,特别是上传大文件的时候,可以需要这样的功能:程序在上传的过程中意外终止了,文件传了一大半,想从断掉了地方继续传:或者想做类似迅雷下载类似的功能,文件太大,今天传一 ...
- 黑盒测试用例设计方法&理论结合实际 -> 等价类划分
一. 概念 等价类划分法是把程序的输入域划分成若干部分(子集),然后从每个部分中选取少数代表性数据作为测试用例.每一类的代表性数据在测试中的作用等价于这一类中的其他值. 二. 等价类划分的应用 等价类 ...
- 使用sklearn进行数据挖掘-房价预测(2)—划分测试集
使用sklearn进行数据挖掘系列文章: 1.使用sklearn进行数据挖掘-房价预测(1) 2.使用sklearn进行数据挖掘-房价预测(2)-划分测试集 3.使用sklearn进行数据挖掘-房价预 ...
- 深入理解JVM - 1 - Java内存区域划分
作者:梦工厂链接:https://www.jianshu.com/p/7ebbe102c1ae来源:简书简书著作权归作者所有,任何形式的转载都请联系作者获得授权并注明出处. Java与C++之间有一堵 ...
随机推荐
- [django]django 在apache2上部署静态文件如何加载
首先找到apache2的conf文件下的httpd.conf,添加如下信息: Alias /static/ E:/wamp/Apache24/www/static/ <Directory E:/ ...
- Collections.shuffle
1.Collections.shuffler 最近有个需求是生成十万级至百万级的所有随机数,最简单的思路是一个个生成,生成新的时候排重,但是这样时间复杂度是o(n^2),网上看了几个博客的解决方法都不 ...
- codevs 1082 线段树练习 3(区间维护)
codevs 1082 线段树练习 3 时间限制: 3 s 空间限制: 128000 KB 题目等级 : 大师 Master 题目描述 Description 给你N个数,有两种操作: 1:给区 ...
- 使用NuGet发布自己的类库包(Library Package)
STEP 1:注册并获取API Key 首先,你需要到NuGet上注册一个新的账号,然后在My Account页面,获取一个API Key,这个过程很简单,我就不作说明了. STEP 2:下载NuGe ...
- [LeetCode] Flip Game 翻转游戏
You are playing the following Flip Game with your friend: Given a string that contains only these tw ...
- [LeetCode] Intersection of Two Linked Lists 求两个链表的交点
Write a program to find the node at which the intersection of two singly linked lists begins. For ex ...
- [LeetCode] Plus One 加一运算
Given a non-negative number represented as an array of digits, plus one to the number. The digits ar ...
- 关于Django 错误 doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS
记录一下 报错 doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS\ 这个问题出现没 ...
- 错误:违反并发性: DeleteCommand 影响了预期 1 条记录中的 0 条
在access的mdb数据库动态更新的过程中,遇到了DeleteCommand出现DBConcurrencyException异常,错误:违反并发性: DeleteCommand 影响了预期 1 条记 ...
- Newick format tree
1. all branches + leaf names + internal supports ((D:0.723274,F:0.567784)1.000000:0.067192,(B:0.2793 ...