添加测试用例生成至文件中的方法

This commit is contained in:
彭宇琦 2020-03-20 20:57:36 +08:00
parent aaf57138be
commit 5ab9e9761e
8 changed files with 457 additions and 234 deletions

View File

@ -7,15 +7,18 @@ import java.util.Set;
import org.openqa.selenium.ElementClickInterceptedException;
import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.StaleElementReferenceException;
import org.openqa.selenium.TimeoutException;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import pres.auxiliary.selenium.event.inter.ClearInter;
import pres.auxiliary.selenium.event.inter.ClickInter;
import pres.auxiliary.selenium.event.inter.DataListEventInter;
import pres.auxiliary.selenium.event.inter.DoubleClickInter;
import pres.auxiliary.selenium.event.inter.GetAttributeValueInter;
import pres.auxiliary.selenium.event.inter.GetTextInter;
import pres.auxiliary.selenium.event.inter.InputInter;
import pres.auxiliary.selenium.event.inter.JudgeKeyInter;
import pres.auxiliary.selenium.event.inter.JudgeTextInter;
import pres.auxiliary.selenium.event.inter.RightClickInter;
@ -648,5 +651,73 @@ public class DataListEvent extends ListElementEvent {
// 返回Event类
return Event.newInstance(getDriver());
}
@Override
public Event clear() {
//自动记录异常
try {
// 为避免出现抛出StaleElementReferenceException页面过期异常则通过循环的方式
// 当抛出异常时则重新获取并操作若未抛出则结束循环
while (true) {
try {
//获取元素
element = judgeElementMode(name);
//修饰元素
elementHight(element);
//操作元素
//调用ClearInter接口的静态方法将从页面上搜索到的控件元素对象传入其中
ClearInter.clear(element);
break;
} catch (StaleElementReferenceException e) {
continue;
}
}
} catch (Exception exception) {
//捕捉到异常后将异常信息记录在工具中并将异常抛出
RecordTool.recordException(exception);
throw exception;
} finally {
RecordTool.recordStep("清空“" + name + "”对应控件中的内容");
}
//返回Event类
return Event.newInstance(getDriver());
}
@Override
public Event input(String text) {
//自动记录异常
try {
// 为避免出现抛出StaleElementReferenceException页面过期异常则通过循环的方式
// 当抛出异常时则重新获取并操作若未抛出则结束循环
while (true) {
try {
//获取元素
element = judgeElementMode(name);
//修饰元素
elementHight(element);
//操作元素
//调用InputInter接口的静态方法将从页面上搜索到的控件元素对象传入其中
InputInter.input(element, text);
break;
} catch (StaleElementReferenceException e) {
continue;
}
}
} catch (Exception exception) {
//捕捉到异常后将异常信息记录在工具中并将异常抛出
RecordTool.recordException(exception);
throw exception;
} finally {
RecordTool.recordStep("向“" + name + "”对应控件中输入“" + text + "");
}
//返回Event类
return Event.newInstance(getDriver());
}
}
}

View File

@ -21,6 +21,6 @@ package pres.auxiliary.selenium.event.inter;
*/
public interface DataListEventInter extends ListElementClickInter, ListElementDoubleClickInter,
ListElementRightClickInter, ListElementGetAttributeValueInter, ListElementGetTextInter,
ListElementJudgeKeyInter, ListElementJudgeTextInter {
ListElementJudgeKeyInter, ListElementJudgeTextInter, ListElementClearInter, ListElementInputInter {
}

View File

@ -374,12 +374,12 @@ public abstract class Case {
}
/**
* 用于整体替换当前存储的内容
* 用于添加带序号的一行文本
* @param label 标签名称枚举
* @param texts 一组内容
* @param text 相应内容
*/
void addFieldText(LabelType label, ArrayList<String> texts) {
fieldTextMap.put(label.getName(), texts);
void addFieldText(LabelType label, int index, String text) {
fieldTextMap.get(label.getName()).add(index + "." + text);
}
/**

View File

@ -3,6 +3,7 @@ package pres.auxiliary.work.n.tcase;
import java.io.File;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
/**
* <p><b>文件名</b>InformationCase.java</p>
@ -94,17 +95,29 @@ public class InformationCase extends Case {
String caseName = "addWholeInformationCase";
//存储标题信息
addFieldText(LabelType.TITLE, getAllLabelText(caseName, LabelType.TITLE));
addFieldText(LabelType.TITLE, getLabelText(caseName, LabelType.TITLE, "1"));
//存储步骤信息
addFieldText(LabelType.STEP, getAllLabelText(caseName, LabelType.STEP));
AtomicInteger index = new AtomicInteger(1);
getAllLabelText(caseName, LabelType.STEP).forEach(text -> {
addFieldText(LabelType.STEP, index.getAndIncrement(), text);
});
//存储预期信息
addFieldText(LabelType.EXCEPT, getAllLabelText(caseName, LabelType.EXCEPT));
index.set(1);
getAllLabelText(caseName, LabelType.EXCEPT).forEach(text -> {
addFieldText(LabelType.EXCEPT, index.getAndIncrement(), text);
});
//存储前置条件信息
addFieldText(LabelType.PRECONDITION, getAllLabelText(caseName, LabelType.PRECONDITION));
index.set(1);
getAllLabelText(caseName, LabelType.PRECONDITION).forEach(text -> {
addFieldText(LabelType.PRECONDITION, index.getAndIncrement(), text);
});
//存储关键词信息
addFieldText(LabelType.KEY, getAllLabelText(caseName, LabelType.KEY));
addFieldText(LabelType.KEY, getLabelText(caseName, LabelType.KEY, "1"));
//存储优先级信息
addFieldText(LabelType.RANK, getAllLabelText(caseName, LabelType.RANK));
addFieldText(LabelType.RANK, getLabelText(caseName, LabelType.RANK, "1"));
return this;
}
@ -119,27 +132,32 @@ public class InformationCase extends Case {
clearFieldText();
// 存储case标签的name属性内容
String caseName = "addUnWholeInformationCase";
//存储步骤信息
AtomicInteger index = new AtomicInteger(1);
//存储标题信息
addFieldText(LabelType.TITLE, getAllLabelText(caseName, LabelType.TITLE));
addFieldText(LabelType.TITLE, getLabelText(caseName, LabelType.TITLE, "1"));
//存储步骤与预期信息
//不填写任何信息
addFieldText(LabelType.STEP, getLabelText(caseName, LabelType.STEP, "1"));
addFieldText(LabelType.EXCEPT, getLabelText(caseName, LabelType.EXCEPT, "2"));
addFieldText(LabelType.STEP, index.get(), getLabelText(caseName, LabelType.STEP, "1"));
addFieldText(LabelType.EXCEPT, index.getAndIncrement(), getLabelText(caseName, LabelType.EXCEPT, "2"));
//只填写所有的必填项信息
addFieldText(LabelType.STEP, getLabelText(caseName, LabelType.STEP, "2"));
addFieldText(LabelType.EXCEPT, getLabelText(caseName, LabelType.EXCEPT, "1"));
addFieldText(LabelType.STEP, index.get(), getLabelText(caseName, LabelType.STEP, "2"));
addFieldText(LabelType.EXCEPT, index.getAndIncrement(), getLabelText(caseName, LabelType.EXCEPT, "1"));
//只填写所有的非必填项信息
addFieldText(LabelType.STEP, getLabelText(caseName, LabelType.STEP, "3"));
addFieldText(LabelType.EXCEPT, getLabelText(caseName, LabelType.EXCEPT, "2"));
addFieldText(LabelType.STEP, index.get(), getLabelText(caseName, LabelType.STEP, "3"));
addFieldText(LabelType.EXCEPT, index.getAndIncrement(), getLabelText(caseName, LabelType.EXCEPT, "2"));
//存储前置条件信息
addFieldText(LabelType.PRECONDITION, getAllLabelText(caseName, LabelType.PRECONDITION));
index.set(1);
getAllLabelText(caseName, LabelType.PRECONDITION).forEach(text -> {
addFieldText(LabelType.PRECONDITION, index.getAndIncrement(), text);
});
//存储关键词信息
addFieldText(LabelType.KEY, getAllLabelText(caseName, LabelType.KEY));
addFieldText(LabelType.KEY, getLabelText(caseName, LabelType.KEY, "1"));
//存储优先级信息
addFieldText(LabelType.RANK, getAllLabelText(caseName, LabelType.RANK));
addFieldText(LabelType.RANK, getLabelText(caseName, LabelType.RANK, "1"));
return this;
}
@ -158,6 +176,9 @@ public class InformationCase extends Case {
clearFieldText();
// 存储case标签的name属性内容
String caseName = "addTextboxCase";
//存储步骤信息
AtomicInteger index = new AtomicInteger(1);
//添加控件名称
wordMap.put(WordType.CONTROL_NAME.getName(), name);
@ -171,9 +192,12 @@ public class InformationCase extends Case {
//----------------------------------------------------------------
//存储前置条件信息
addFieldText(LabelType.PRECONDITION, getAllLabelText(caseName, LabelType.PRECONDITION));
index.set(1);
getAllLabelText(caseName, LabelType.PRECONDITION).forEach(text -> {
addFieldText(LabelType.PRECONDITION, index.getAndIncrement(), text);
});
//存储关键词信息
addFieldText(LabelType.KEY, getAllLabelText(caseName, LabelType.KEY));
addFieldText(LabelType.KEY, getLabelText(caseName, LabelType.KEY, "1"));
//存储优先级信息
addFieldText(LabelType.RANK, getLabelText(caseName, LabelType.RANK, isMust ? "1" : "2"));
@ -202,6 +226,9 @@ public class InformationCase extends Case {
clearFieldText();
// 存储case标签的name属性内容
String caseName = "addTextboxCase";
//存储步骤信息
AtomicInteger index = new AtomicInteger(1);
//添加控件名称
wordMap.put(WordType.CONTROL_NAME.getName(), name);
@ -225,47 +252,50 @@ public class InformationCase extends Case {
wordMap.put(WordType.INPUT_MIN_LENGTH.getName(), String.valueOf(minLen));
//小于最小限制
addFieldText(LabelType.STEP, getLabelText(caseName, LabelType.STEP, "4"));
addFieldText(LabelType.EXCEPT, getLabelText(caseName, LabelType.EXCEPT, "2"));
addFieldText(LabelType.STEP, index.get(), getLabelText(caseName, LabelType.STEP, "4"));
addFieldText(LabelType.EXCEPT, index.getAndIncrement(), getLabelText(caseName, LabelType.EXCEPT, "2"));
//等于最小限制
addFieldText(LabelType.STEP, getLabelText(caseName, LabelType.STEP, "5"));
addFieldText(LabelType.EXCEPT, getLabelText(caseName, LabelType.EXCEPT, "1"));
addFieldText(LabelType.STEP, index.get(), getLabelText(caseName, LabelType.STEP, "5"));
addFieldText(LabelType.EXCEPT, index.getAndIncrement(), getLabelText(caseName, LabelType.EXCEPT, "1"));
} else if (minLen == 0 && maxLen != 0) {
//存储最大输入限制
wordMap.put(WordType.INPUT_MAX_LENGTH.getName(), String.valueOf(maxLen));
//大于最大限制
addFieldText(LabelType.STEP, getLabelText(caseName, LabelType.STEP, "6"));
addFieldText(LabelType.EXCEPT, getLabelText(caseName, LabelType.EXCEPT, "2"));
addFieldText(LabelType.STEP, index.get(), getLabelText(caseName, LabelType.STEP, "6"));
addFieldText(LabelType.EXCEPT, index.getAndIncrement(), getLabelText(caseName, LabelType.EXCEPT, "2"));
//等于最大限制
addFieldText(LabelType.STEP, getLabelText(caseName, LabelType.STEP, "7"));
addFieldText(LabelType.EXCEPT, getLabelText(caseName, LabelType.EXCEPT, "1"));
addFieldText(LabelType.STEP, index.get(), getLabelText(caseName, LabelType.STEP, "7"));
addFieldText(LabelType.EXCEPT, index.getAndIncrement(), getLabelText(caseName, LabelType.EXCEPT, "1"));
} else {
//若都不为0则将相应的内容进行存储且判断最大长度与最小长度是否传反若传反则调换顺序
wordMap.put(WordType.INPUT_MIN_LENGTH.getName(), String.valueOf(minLen < maxLen ? minLen : maxLen));
wordMap.put(WordType.INPUT_MAX_LENGTH.getName(), String.valueOf(minLen < maxLen ? maxLen : minLen));
//小于最小限制
addFieldText(LabelType.STEP, getLabelText(caseName, LabelType.STEP, "4"));
addFieldText(LabelType.EXCEPT, getLabelText(caseName, LabelType.EXCEPT, "2"));
addFieldText(LabelType.STEP, index.get(), getLabelText(caseName, LabelType.STEP, "4"));
addFieldText(LabelType.EXCEPT, index.getAndIncrement(), getLabelText(caseName, LabelType.EXCEPT, "2"));
//等于最小限制
addFieldText(LabelType.STEP, getLabelText(caseName, LabelType.STEP, "5"));
addFieldText(LabelType.EXCEPT, getLabelText(caseName, LabelType.EXCEPT, "1"));
addFieldText(LabelType.STEP, index.get(), getLabelText(caseName, LabelType.STEP, "5"));
addFieldText(LabelType.EXCEPT, index.getAndIncrement(), getLabelText(caseName, LabelType.EXCEPT, "1"));
//大于最大限制
addFieldText(LabelType.STEP, getLabelText(caseName, LabelType.STEP, "6"));
addFieldText(LabelType.EXCEPT, getLabelText(caseName, LabelType.EXCEPT, "2"));
addFieldText(LabelType.STEP, index.get(), getLabelText(caseName, LabelType.STEP, "6"));
addFieldText(LabelType.EXCEPT, index.getAndIncrement(), getLabelText(caseName, LabelType.EXCEPT, "2"));
//若最大最小限制相等则不添加该条用例
if (minLen != maxLen) {
//等于最大限制
addFieldText(LabelType.STEP, getLabelText(caseName, LabelType.STEP, "7"));
addFieldText(LabelType.EXCEPT, getLabelText(caseName, LabelType.EXCEPT, "1"));
addFieldText(LabelType.STEP, index.get(), getLabelText(caseName, LabelType.STEP, "7"));
addFieldText(LabelType.EXCEPT, index.getAndIncrement(), getLabelText(caseName, LabelType.EXCEPT, "1"));
}
}
//----------------------------------------------------------------------
//存储前置条件信息
addFieldText(LabelType.PRECONDITION, getAllLabelText(caseName, LabelType.PRECONDITION));
index.set(1);
getAllLabelText(caseName, LabelType.PRECONDITION).forEach(text -> {
addFieldText(LabelType.PRECONDITION, index.getAndIncrement(), text);
});
//存储关键词信息
addFieldText(LabelType.KEY, getAllLabelText(caseName, LabelType.KEY));
addFieldText(LabelType.KEY, getLabelText(caseName, LabelType.KEY, "1"));
//存储优先级信息
addFieldText(LabelType.RANK, getLabelText(caseName, LabelType.RANK, isMust ? "1" : "2"));
@ -294,6 +324,9 @@ public class InformationCase extends Case {
clearFieldText();
// 存储case标签的name属性内容
String caseName = "addTextboxCase";
//存储步骤信息
AtomicInteger index = new AtomicInteger(1);
//添加控件名称
wordMap.put(WordType.CONTROL_NAME.getName(), name);
@ -324,37 +357,37 @@ public class InformationCase extends Case {
throw new CaseContentException("大小限制不能同时为极值");
} else if (min == MIN_NUMBER && max != MAX_NUMBER) {
//大于最大限制
addFieldText(LabelType.STEP, getLabelText(caseName, LabelType.STEP, "10"));
addFieldText(LabelType.EXCEPT, getLabelText(caseName, LabelType.EXCEPT, "2"));
addFieldText(LabelType.STEP, index.get(), getLabelText(caseName, LabelType.STEP, "10"));
addFieldText(LabelType.EXCEPT, index.getAndIncrement(), getLabelText(caseName, LabelType.EXCEPT, "2"));
//等于最大限制
addFieldText(LabelType.STEP, getLabelText(caseName, LabelType.STEP, "11"));
addFieldText(LabelType.EXCEPT, getLabelText(caseName, LabelType.EXCEPT, "1"));
addFieldText(LabelType.STEP, index.get(), getLabelText(caseName, LabelType.STEP, "11"));
addFieldText(LabelType.EXCEPT, index.getAndIncrement(), getLabelText(caseName, LabelType.EXCEPT, "1"));
//小于最小负数限制
addFieldText(LabelType.STEP, getLabelText(caseName, LabelType.STEP, "8"));
addFieldText(LabelType.EXCEPT, getLabelText(caseName, LabelType.EXCEPT, "5"));
addFieldText(LabelType.STEP, index.get(), getLabelText(caseName, LabelType.STEP, "8"));
addFieldText(LabelType.EXCEPT, index.getAndIncrement(), getLabelText(caseName, LabelType.EXCEPT, "5"));
} else if (min != MIN_NUMBER && max == MAX_NUMBER) {
//小于最小限制
addFieldText(LabelType.STEP, getLabelText(caseName, LabelType.STEP, "8"));
addFieldText(LabelType.EXCEPT, getLabelText(caseName, LabelType.EXCEPT, "2"));
addFieldText(LabelType.STEP, index.get(), getLabelText(caseName, LabelType.STEP, "8"));
addFieldText(LabelType.EXCEPT, index.getAndIncrement(), getLabelText(caseName, LabelType.EXCEPT, "2"));
//等于最小限制
addFieldText(LabelType.STEP, getLabelText(caseName, LabelType.STEP, "9"));
addFieldText(LabelType.EXCEPT, getLabelText(caseName, LabelType.EXCEPT, "1"));
addFieldText(LabelType.STEP, index.get(), getLabelText(caseName, LabelType.STEP, "9"));
addFieldText(LabelType.EXCEPT, index.getAndIncrement(), getLabelText(caseName, LabelType.EXCEPT, "1"));
//大于最大正数限制
addFieldText(LabelType.STEP, getLabelText(caseName, LabelType.STEP, "10"));
addFieldText(LabelType.EXCEPT, getLabelText(caseName, LabelType.EXCEPT, "5"));
addFieldText(LabelType.STEP, index.get(), getLabelText(caseName, LabelType.STEP, "10"));
addFieldText(LabelType.EXCEPT, index.getAndIncrement(), getLabelText(caseName, LabelType.EXCEPT, "5"));
} else {
//小于最小限制
addFieldText(LabelType.STEP, getLabelText(caseName, LabelType.STEP, "8"));
addFieldText(LabelType.EXCEPT, getLabelText(caseName, LabelType.EXCEPT, "2"));
addFieldText(LabelType.STEP, index.get(), getLabelText(caseName, LabelType.STEP, "8"));
addFieldText(LabelType.EXCEPT, index.getAndIncrement(), getLabelText(caseName, LabelType.EXCEPT, "2"));
//等于最小限制
addFieldText(LabelType.STEP, getLabelText(caseName, LabelType.STEP, "9"));
addFieldText(LabelType.EXCEPT, getLabelText(caseName, LabelType.EXCEPT, "1"));
addFieldText(LabelType.STEP, index.get(), getLabelText(caseName, LabelType.STEP, "9"));
addFieldText(LabelType.EXCEPT, index.getAndIncrement(), getLabelText(caseName, LabelType.EXCEPT, "1"));
//大于最大限制
addFieldText(LabelType.STEP, getLabelText(caseName, LabelType.STEP, "10"));
addFieldText(LabelType.EXCEPT, getLabelText(caseName, LabelType.EXCEPT, "2"));
addFieldText(LabelType.STEP, index.get(), getLabelText(caseName, LabelType.STEP, "10"));
addFieldText(LabelType.EXCEPT, index.getAndIncrement(), getLabelText(caseName, LabelType.EXCEPT, "2"));
//等于最大限制
addFieldText(LabelType.STEP, getLabelText(caseName, LabelType.STEP, "11"));
addFieldText(LabelType.EXCEPT, getLabelText(caseName, LabelType.EXCEPT, "1"));
addFieldText(LabelType.STEP, index.get(), getLabelText(caseName, LabelType.STEP, "11"));
addFieldText(LabelType.EXCEPT, index.getAndIncrement(), getLabelText(caseName, LabelType.EXCEPT, "1"));
}
//若传入的小数位数大于0则添加小数位相关的用例
@ -362,22 +395,25 @@ public class InformationCase extends Case {
//存储小数位数
wordMap.put(WordType.INPUT_DECIMALS.getName(), String.valueOf(decimals));
//等于最小限制
addFieldText(LabelType.STEP, getLabelText(caseName, LabelType.STEP, "14"));
addFieldText(LabelType.EXCEPT, getLabelText(caseName, LabelType.EXCEPT, "6"));
addFieldText(LabelType.STEP, index.get(), getLabelText(caseName, LabelType.STEP, "14"));
addFieldText(LabelType.EXCEPT, index.getAndIncrement(), getLabelText(caseName, LabelType.EXCEPT, "6"));
//大于最大限制
addFieldText(LabelType.STEP, getLabelText(caseName, LabelType.STEP, "15"));
addFieldText(LabelType.EXCEPT, getLabelText(caseName, LabelType.EXCEPT, "1"));
addFieldText(LabelType.STEP, index.get(), getLabelText(caseName, LabelType.STEP, "15"));
addFieldText(LabelType.EXCEPT, index.getAndIncrement(), getLabelText(caseName, LabelType.EXCEPT, "1"));
//等于最大限制
addFieldText(LabelType.STEP, getLabelText(caseName, LabelType.STEP, "16"));
addFieldText(LabelType.EXCEPT, getLabelText(caseName, LabelType.EXCEPT, "1"));
addFieldText(LabelType.STEP, index.get(), getLabelText(caseName, LabelType.STEP, "16"));
addFieldText(LabelType.EXCEPT, index.getAndIncrement(), getLabelText(caseName, LabelType.EXCEPT, "1"));
}
//----------------------------------------------------------------------
//存储前置条件信息
addFieldText(LabelType.PRECONDITION, getAllLabelText(caseName, LabelType.PRECONDITION));
index.set(1);
getAllLabelText(caseName, LabelType.PRECONDITION).forEach(text -> {
addFieldText(LabelType.PRECONDITION, index.getAndIncrement(), text);
});
//存储关键词信息
addFieldText(LabelType.KEY, getAllLabelText(caseName, LabelType.KEY));
addFieldText(LabelType.KEY, getLabelText(caseName, LabelType.KEY, "1"));
//存储优先级信息
addFieldText(LabelType.RANK, getLabelText(caseName, LabelType.RANK, isMust ? "1" : "2"));
@ -398,6 +434,9 @@ public class InformationCase extends Case {
clearFieldText();
// 存储case标签的name属性内容
String caseName = "addPhoneCase";
//存储步骤信息
AtomicInteger index = new AtomicInteger(1);
//添加控件名称
wordMap.put(WordType.CONTROL_NAME.getName(), name);
//转换输入限制为集合类型
@ -414,35 +453,38 @@ public class InformationCase extends Case {
//添加手机相关的测试用例
if (phoneRules.contains(PhoneType.MOBLE)) {
//大于11位
addFieldText(LabelType.STEP, getLabelText(caseName, LabelType.STEP, "3"));
addFieldText(LabelType.EXCEPT, getLabelText(caseName, LabelType.EXCEPT, "2"));
addFieldText(LabelType.STEP, index.get(), getLabelText(caseName, LabelType.STEP, "3"));
addFieldText(LabelType.EXCEPT, index.getAndIncrement(), getLabelText(caseName, LabelType.EXCEPT, "2"));
//小于11位
addFieldText(LabelType.STEP, getLabelText(caseName, LabelType.STEP, "4"));
addFieldText(LabelType.EXCEPT, getLabelText(caseName, LabelType.EXCEPT, "2"));
addFieldText(LabelType.STEP, index.get(), getLabelText(caseName, LabelType.STEP, "4"));
addFieldText(LabelType.EXCEPT, index.getAndIncrement(), getLabelText(caseName, LabelType.EXCEPT, "2"));
}
//添加座机相关的测试用例
if (phoneRules.contains(PhoneType.FIXED)) {
//大于7位
addFieldText(LabelType.STEP, getLabelText(caseName, LabelType.STEP, "5"));
addFieldText(LabelType.EXCEPT, getLabelText(caseName, LabelType.EXCEPT, "2"));
addFieldText(LabelType.STEP, index.get(), getLabelText(caseName, LabelType.STEP, "5"));
addFieldText(LabelType.EXCEPT, index.getAndIncrement(), getLabelText(caseName, LabelType.EXCEPT, "2"));
//小于7位
addFieldText(LabelType.STEP, getLabelText(caseName, LabelType.STEP, "6"));
addFieldText(LabelType.EXCEPT, getLabelText(caseName, LabelType.EXCEPT, "2"));
addFieldText(LabelType.STEP, index.get(), getLabelText(caseName, LabelType.STEP, "6"));
addFieldText(LabelType.EXCEPT, index.getAndIncrement(), getLabelText(caseName, LabelType.EXCEPT, "2"));
//区位号
addFieldText(LabelType.STEP, getLabelText(caseName, LabelType.STEP, "1"));
addFieldText(LabelType.EXCEPT, getLabelText(caseName, LabelType.EXCEPT, "1"));
addFieldText(LabelType.STEP, index.get(), getLabelText(caseName, LabelType.STEP, "1"));
addFieldText(LabelType.EXCEPT, index.getAndIncrement(), getLabelText(caseName, LabelType.EXCEPT, "1"));
}
//长度符合但不和规则的用例
addFieldText(LabelType.STEP, getLabelText(caseName, LabelType.STEP, "7"));
addFieldText(LabelType.EXCEPT, getLabelText(caseName, LabelType.EXCEPT, "2"));
addFieldText(LabelType.STEP, index.get(), getLabelText(caseName, LabelType.STEP, "7"));
addFieldText(LabelType.EXCEPT, index.getAndIncrement(), getLabelText(caseName, LabelType.EXCEPT, "2"));
//----------------------------------------------------------------------
//存储前置条件信息
addFieldText(LabelType.PRECONDITION, getAllLabelText(caseName, LabelType.PRECONDITION));
index.set(1);
getAllLabelText(caseName, LabelType.PRECONDITION).forEach(text -> {
addFieldText(LabelType.PRECONDITION, index.getAndIncrement(), text);
});
//存储关键词信息
addFieldText(LabelType.KEY, getAllLabelText(caseName, LabelType.KEY));
addFieldText(LabelType.KEY, getLabelText(caseName, LabelType.KEY, "1"));
//存储优先级信息
addFieldText(LabelType.RANK, getLabelText(caseName, LabelType.RANK, isMust ? "1" : "2"));
@ -462,6 +504,9 @@ public class InformationCase extends Case {
clearFieldText();
// 存储case标签的name属性内容
String caseName = "addIDCardCase";
//存储步骤信息
AtomicInteger index = new AtomicInteger(1);
//添加控件名称
wordMap.put(WordType.CONTROL_NAME.getName(), name);
@ -474,34 +519,37 @@ public class InformationCase extends Case {
textboxCommonCase(isMust, isRepeat, isClear, InputRuleType.NUM);
//输入15位
addFieldText(LabelType.STEP, getLabelText(caseName, LabelType.STEP, "3"));
addFieldText(LabelType.EXCEPT, getLabelText(caseName, LabelType.EXCEPT, "1"));
addFieldText(LabelType.STEP, index.get(), getLabelText(caseName, LabelType.STEP, "3"));
addFieldText(LabelType.EXCEPT, index.getAndIncrement(), getLabelText(caseName, LabelType.EXCEPT, "1"));
//输入18位
addFieldText(LabelType.STEP, getLabelText(caseName, LabelType.STEP, "4"));
addFieldText(LabelType.EXCEPT, getLabelText(caseName, LabelType.EXCEPT, "1"));
addFieldText(LabelType.STEP, index.get(), getLabelText(caseName, LabelType.STEP, "4"));
addFieldText(LabelType.EXCEPT, index.getAndIncrement(), getLabelText(caseName, LabelType.EXCEPT, "1"));
//输入末尾带Xx
addFieldText(LabelType.STEP, getLabelText(caseName, LabelType.STEP, "5"));
addFieldText(LabelType.EXCEPT, getLabelText(caseName, LabelType.EXCEPT, "1"));
addFieldText(LabelType.STEP, index.get(), getLabelText(caseName, LabelType.STEP, "5"));
addFieldText(LabelType.EXCEPT, index.getAndIncrement(), getLabelText(caseName, LabelType.EXCEPT, "1"));
//输入大于18位
addFieldText(LabelType.STEP, getLabelText(caseName, LabelType.STEP, "6"));
addFieldText(LabelType.EXCEPT, getLabelText(caseName, LabelType.EXCEPT, "2"));
addFieldText(LabelType.STEP, index.get(), getLabelText(caseName, LabelType.STEP, "6"));
addFieldText(LabelType.EXCEPT, index.getAndIncrement(), getLabelText(caseName, LabelType.EXCEPT, "2"));
//输入小于18位大于15位
addFieldText(LabelType.STEP, getLabelText(caseName, LabelType.STEP, "7"));
addFieldText(LabelType.EXCEPT, getLabelText(caseName, LabelType.EXCEPT, "2"));
addFieldText(LabelType.STEP, index.get(), getLabelText(caseName, LabelType.STEP, "7"));
addFieldText(LabelType.EXCEPT, index.getAndIncrement(), getLabelText(caseName, LabelType.EXCEPT, "2"));
//输入小于15位
addFieldText(LabelType.STEP, getLabelText(caseName, LabelType.STEP, "8"));
addFieldText(LabelType.EXCEPT, getLabelText(caseName, LabelType.EXCEPT, "2"));
addFieldText(LabelType.STEP, index.get(), getLabelText(caseName, LabelType.STEP, "8"));
addFieldText(LabelType.EXCEPT, index.getAndIncrement(), getLabelText(caseName, LabelType.EXCEPT, "2"));
//输入不符合规则
addFieldText(LabelType.STEP, getLabelText(caseName, LabelType.STEP, "9"));
addFieldText(LabelType.EXCEPT, getLabelText(caseName, LabelType.EXCEPT, "2"));
addFieldText(LabelType.STEP, index.get(), getLabelText(caseName, LabelType.STEP, "9"));
addFieldText(LabelType.EXCEPT, index.getAndIncrement(), getLabelText(caseName, LabelType.EXCEPT, "2"));
//----------------------------------------------------------------------
//存储前置条件信息
addFieldText(LabelType.PRECONDITION, getAllLabelText(caseName, LabelType.PRECONDITION));
index.set(1);
getAllLabelText(caseName, LabelType.PRECONDITION).forEach(text -> {
addFieldText(LabelType.PRECONDITION, index.getAndIncrement(), text);
});
//存储关键词信息
addFieldText(LabelType.KEY, getAllLabelText(caseName, LabelType.KEY));
addFieldText(LabelType.KEY, getLabelText(caseName, LabelType.KEY, "1"));
//存储优先级信息
addFieldText(LabelType.RANK, getLabelText(caseName, LabelType.RANK, isMust ? "1" : "2"));
@ -521,6 +569,9 @@ public class InformationCase extends Case {
clearFieldText();
// 存储case标签的name属性内容
String caseName = "addSelectboxCase";
//存储步骤信息
AtomicInteger index = new AtomicInteger(1);
//添加控件名称
wordMap.put(WordType.CONTROL_NAME.getName(), name);
@ -530,28 +581,31 @@ public class InformationCase extends Case {
//----------------------------------------------------------------------
//存储步骤与预期信息
//选择选项后清空
addFieldText(LabelType.STEP, getLabelText(caseName, LabelType.STEP, "4"));
addFieldText(LabelType.EXCEPT, getLabelText(caseName, LabelType.EXCEPT, hasEmpty ? "4" : "3"));
addFieldText(LabelType.STEP, index.get(), getLabelText(caseName, LabelType.STEP, "4"));
addFieldText(LabelType.EXCEPT, index.getAndIncrement(), getLabelText(caseName, LabelType.EXCEPT, hasEmpty ? "4" : "3"));
//添加空选项用例
if (hasEmpty) {
addFieldText(LabelType.STEP, getLabelText(caseName, LabelType.STEP, "1"));
addFieldText(LabelType.EXCEPT, getLabelText(caseName, LabelType.EXCEPT, isMust ? "1" : "2"));
addFieldText(LabelType.STEP, index.get(), getLabelText(caseName, LabelType.STEP, "1"));
addFieldText(LabelType.EXCEPT, index.getAndIncrement(), getLabelText(caseName, LabelType.EXCEPT, isMust ? "1" : "2"));
}
//添加选择第一个选项
addFieldText(LabelType.STEP, getLabelText(caseName, LabelType.STEP, "2"));
addFieldText(LabelType.EXCEPT, getLabelText(caseName, LabelType.EXCEPT, "1"));
addFieldText(LabelType.STEP, index.get(), getLabelText(caseName, LabelType.STEP, "2"));
addFieldText(LabelType.EXCEPT, index.getAndIncrement(), getLabelText(caseName, LabelType.EXCEPT, "1"));
//添加选择最后一个选项
addFieldText(LabelType.STEP, getLabelText(caseName, LabelType.STEP, "3"));
addFieldText(LabelType.EXCEPT, getLabelText(caseName, LabelType.EXCEPT, "1"));
addFieldText(LabelType.STEP, index.get(), getLabelText(caseName, LabelType.STEP, "3"));
addFieldText(LabelType.EXCEPT, index.getAndIncrement(), getLabelText(caseName, LabelType.EXCEPT, "1"));
//----------------------------------------------------------------------
//存储前置条件信息
addFieldText(LabelType.PRECONDITION, getAllLabelText(caseName, LabelType.PRECONDITION));
index.set(1);
getAllLabelText(caseName, LabelType.PRECONDITION).forEach(text -> {
addFieldText(LabelType.PRECONDITION, index.getAndIncrement(), text);
});
//存储关键词信息
addFieldText(LabelType.KEY, getAllLabelText(caseName, LabelType.KEY));
addFieldText(LabelType.KEY, getLabelText(caseName, LabelType.KEY, "1"));
//存储优先级信息
addFieldText(LabelType.RANK, getLabelText(caseName, LabelType.RANK, isMust ? "1" : "2"));
@ -568,6 +622,9 @@ public class InformationCase extends Case {
clearFieldText();
// 存储case标签的name属性内容
String caseName = "addRadioButtonCase";
//存储步骤信息
AtomicInteger index = new AtomicInteger(1);
//添加控件名称
wordMap.put(WordType.CONTROL_NAME.getName(), name);
@ -577,31 +634,34 @@ public class InformationCase extends Case {
//----------------------------------------------------------------------
//存储步骤与预期信息
//选择选项后清空
addFieldText(LabelType.STEP, getLabelText(caseName, LabelType.STEP, "5"));
addFieldText(LabelType.EXCEPT, getLabelText(caseName, LabelType.EXCEPT, "4"));
addFieldText(LabelType.STEP, index.get(), getLabelText(caseName, LabelType.STEP, "5"));
addFieldText(LabelType.EXCEPT, index.getAndIncrement(), getLabelText(caseName, LabelType.EXCEPT, "4"));
//依次选择选项
addFieldText(LabelType.STEP, getLabelText(caseName, LabelType.STEP, "1"));
addFieldText(LabelType.EXCEPT, getLabelText(caseName, LabelType.EXCEPT, "3"));
addFieldText(LabelType.STEP, index.get(), getLabelText(caseName, LabelType.STEP, "1"));
addFieldText(LabelType.EXCEPT, index.getAndIncrement(), getLabelText(caseName, LabelType.EXCEPT, "3"));
//不改变默认选项
addFieldText(LabelType.STEP, getLabelText(caseName, LabelType.STEP, "2"));
addFieldText(LabelType.EXCEPT, getLabelText(caseName, LabelType.EXCEPT, "1"));
addFieldText(LabelType.STEP, index.get(), getLabelText(caseName, LabelType.STEP, "2"));
addFieldText(LabelType.EXCEPT, index.getAndIncrement(), getLabelText(caseName, LabelType.EXCEPT, "1"));
//选第一个
addFieldText(LabelType.STEP, getLabelText(caseName, LabelType.STEP, "3"));
addFieldText(LabelType.EXCEPT, getLabelText(caseName, LabelType.EXCEPT, "1"));
addFieldText(LabelType.STEP, index.get(), getLabelText(caseName, LabelType.STEP, "3"));
addFieldText(LabelType.EXCEPT, index.getAndIncrement(), getLabelText(caseName, LabelType.EXCEPT, "1"));
//选最后一个
addFieldText(LabelType.STEP, getLabelText(caseName, LabelType.STEP, "4"));
addFieldText(LabelType.EXCEPT, getLabelText(caseName, LabelType.EXCEPT, "1"));
addFieldText(LabelType.STEP, index.get(), getLabelText(caseName, LabelType.STEP, "4"));
addFieldText(LabelType.EXCEPT, index.getAndIncrement(), getLabelText(caseName, LabelType.EXCEPT, "1"));
//----------------------------------------------------------------------
//存储前置条件信息
addFieldText(LabelType.PRECONDITION, getAllLabelText(caseName, LabelType.PRECONDITION));
index.set(1);
getAllLabelText(caseName, LabelType.PRECONDITION).forEach(text -> {
addFieldText(LabelType.PRECONDITION, index.getAndIncrement(), text);
});
//存储关键词信息
addFieldText(LabelType.KEY, getAllLabelText(caseName, LabelType.KEY));
addFieldText(LabelType.KEY, getLabelText(caseName, LabelType.KEY, "1"));
//存储优先级信息
addFieldText(LabelType.RANK, getLabelText(caseName, LabelType.RANK, "1"));
@ -619,6 +679,9 @@ public class InformationCase extends Case {
clearFieldText();
// 存储case标签的name属性内容
String caseName = "addCheckboxCase";
//存储步骤信息
AtomicInteger index = new AtomicInteger(1);
//添加控件名称
wordMap.put(WordType.CONTROL_NAME.getName(), name);
@ -628,34 +691,37 @@ public class InformationCase extends Case {
//----------------------------------------------------------------------
//存储步骤与预期信息
//依次选择选项
addFieldText(LabelType.STEP, getLabelText(caseName, LabelType.STEP, "1"));
addFieldText(LabelType.EXCEPT, getLabelText(caseName, LabelType.EXCEPT, "3"));
addFieldText(LabelType.STEP, index.get(), getLabelText(caseName, LabelType.STEP, "1"));
addFieldText(LabelType.EXCEPT, index.getAndIncrement(), getLabelText(caseName, LabelType.EXCEPT, "3"));
//再次依次选择选项
addFieldText(LabelType.STEP, getLabelText(caseName, LabelType.STEP, "2"));
addFieldText(LabelType.EXCEPT, getLabelText(caseName, LabelType.EXCEPT, "4"));
addFieldText(LabelType.STEP, index.get(), getLabelText(caseName, LabelType.STEP, "2"));
addFieldText(LabelType.EXCEPT, index.getAndIncrement(), getLabelText(caseName, LabelType.EXCEPT, "4"));
//不进行选择
addFieldText(LabelType.STEP, getLabelText(caseName, LabelType.STEP, "3"));
addFieldText(LabelType.EXCEPT, getLabelText(caseName, LabelType.EXCEPT, isMust ? "2" : "1"));
addFieldText(LabelType.STEP, index.get(), getLabelText(caseName, LabelType.STEP, "3"));
addFieldText(LabelType.EXCEPT, index.getAndIncrement(), getLabelText(caseName, LabelType.EXCEPT, isMust ? "2" : "1"));
//选择第一个
addFieldText(LabelType.STEP, getLabelText(caseName, LabelType.STEP, "4"));
addFieldText(LabelType.EXCEPT, getLabelText(caseName, LabelType.EXCEPT, "1"));
addFieldText(LabelType.STEP, index.get(), getLabelText(caseName, LabelType.STEP, "4"));
addFieldText(LabelType.EXCEPT, index.getAndIncrement(), getLabelText(caseName, LabelType.EXCEPT, "1"));
//选择最后一个
addFieldText(LabelType.STEP, getLabelText(caseName, LabelType.STEP, "5"));
addFieldText(LabelType.EXCEPT, getLabelText(caseName, LabelType.EXCEPT, "1"));
addFieldText(LabelType.STEP, index.get(), getLabelText(caseName, LabelType.STEP, "5"));
addFieldText(LabelType.EXCEPT, index.getAndIncrement(), getLabelText(caseName, LabelType.EXCEPT, "1"));
//选择多个
addFieldText(LabelType.STEP, getLabelText(caseName, LabelType.STEP, "6"));
addFieldText(LabelType.EXCEPT, getLabelText(caseName, LabelType.EXCEPT, "1"));
addFieldText(LabelType.STEP, index.get(), getLabelText(caseName, LabelType.STEP, "6"));
addFieldText(LabelType.EXCEPT, index.getAndIncrement(), getLabelText(caseName, LabelType.EXCEPT, "1"));
//----------------------------------------------------------------------
//存储前置条件信息
addFieldText(LabelType.PRECONDITION, getAllLabelText(caseName, LabelType.PRECONDITION));
index.set(1);
getAllLabelText(caseName, LabelType.PRECONDITION).forEach(text -> {
addFieldText(LabelType.PRECONDITION, index.getAndIncrement(), text);
});
//存储关键词信息
addFieldText(LabelType.KEY, getAllLabelText(caseName, LabelType.KEY));
addFieldText(LabelType.KEY, getLabelText(caseName, LabelType.KEY, "1"));
//存储优先级信息
addFieldText(LabelType.RANK, getLabelText(caseName, LabelType.RANK, "1"));
@ -675,6 +741,9 @@ public class InformationCase extends Case {
clearFieldText();
// 存储case标签的name属性内容
String caseName = "addDateCase";
//存储步骤信息
AtomicInteger index = new AtomicInteger(1);
//添加控件名称
wordMap.put(WordType.CONTROL_NAME.getName(), name);
@ -688,9 +757,12 @@ public class InformationCase extends Case {
//----------------------------------------------------------------------
//存储前置条件信息
addFieldText(LabelType.PRECONDITION, getAllLabelText(caseName, LabelType.PRECONDITION));
index.set(1);
getAllLabelText(caseName, LabelType.PRECONDITION).forEach(text -> {
addFieldText(LabelType.PRECONDITION, index.getAndIncrement(), text);
});
//存储关键词信息
addFieldText(LabelType.KEY, getAllLabelText(caseName, LabelType.KEY));
addFieldText(LabelType.KEY, getLabelText(caseName, LabelType.KEY, "1"));
//存储优先级信息
addFieldText(LabelType.RANK, getLabelText(caseName, LabelType.RANK, "1"));
@ -710,6 +782,9 @@ public class InformationCase extends Case {
clearFieldText();
// 存储case标签的name属性内容
String caseName = "addDateCase";
//存储步骤信息
AtomicInteger index = new AtomicInteger(1);
//添加控件名称
wordMap.put(WordType.CONTROL_NAME.getName(), name);
@ -723,18 +798,21 @@ public class InformationCase extends Case {
wordMap.put(WordType.END_DATE.getName(), endDateName);
//大于结束时间
addFieldText(LabelType.STEP, getLabelText(caseName, LabelType.STEP, "6"));
addFieldText(LabelType.EXCEPT, getLabelText(caseName, LabelType.EXCEPT, "2"));
addFieldText(LabelType.STEP, index.get(), getLabelText(caseName, LabelType.STEP, "6"));
addFieldText(LabelType.EXCEPT, index.getAndIncrement(), getLabelText(caseName, LabelType.EXCEPT, "2"));
//等于结束时间
addFieldText(LabelType.STEP, getLabelText(caseName, LabelType.STEP, "7"));
addFieldText(LabelType.EXCEPT, getLabelText(caseName, LabelType.EXCEPT, "1"));
addFieldText(LabelType.STEP, index.get(), getLabelText(caseName, LabelType.STEP, "7"));
addFieldText(LabelType.EXCEPT, index.getAndIncrement(), getLabelText(caseName, LabelType.EXCEPT, "1"));
//----------------------------------------------------------------------
//存储前置条件信息
addFieldText(LabelType.PRECONDITION, getAllLabelText(caseName, LabelType.PRECONDITION));
index.set(1);
getAllLabelText(caseName, LabelType.PRECONDITION).forEach(text -> {
addFieldText(LabelType.PRECONDITION, index.getAndIncrement(), text);
});
//存储关键词信息
addFieldText(LabelType.KEY, getAllLabelText(caseName, LabelType.KEY));
addFieldText(LabelType.KEY, getLabelText(caseName, LabelType.KEY, "1"));
//存储优先级信息
addFieldText(LabelType.RANK, getLabelText(caseName, LabelType.RANK, "1"));
@ -754,6 +832,9 @@ public class InformationCase extends Case {
clearFieldText();
// 存储case标签的name属性内容
String caseName = "addDateCase";
//存储步骤信息
AtomicInteger index = new AtomicInteger(1);
//添加控件名称
wordMap.put(WordType.CONTROL_NAME.getName(), name);
@ -767,18 +848,21 @@ public class InformationCase extends Case {
wordMap.put(WordType.START_DATE.getName(), startDateName);
//小于开始时间
addFieldText(LabelType.STEP, getLabelText(caseName, LabelType.STEP, "8"));
addFieldText(LabelType.EXCEPT, getLabelText(caseName, LabelType.EXCEPT, "2"));
addFieldText(LabelType.STEP, index.get(), getLabelText(caseName, LabelType.STEP, "8"));
addFieldText(LabelType.EXCEPT, index.getAndIncrement(), getLabelText(caseName, LabelType.EXCEPT, "2"));
//等于开始时间
addFieldText(LabelType.STEP, getLabelText(caseName, LabelType.STEP, "9"));
addFieldText(LabelType.EXCEPT, getLabelText(caseName, LabelType.EXCEPT, "1"));
addFieldText(LabelType.STEP, index.get(), getLabelText(caseName, LabelType.STEP, "9"));
addFieldText(LabelType.EXCEPT, index.getAndIncrement(), getLabelText(caseName, LabelType.EXCEPT, "1"));
//----------------------------------------------------------------------
//存储前置条件信息
addFieldText(LabelType.PRECONDITION, getAllLabelText(caseName, LabelType.PRECONDITION));
index.set(1);
getAllLabelText(caseName, LabelType.PRECONDITION).forEach(text -> {
addFieldText(LabelType.PRECONDITION, index.getAndIncrement(), text);
});
//存储关键词信息
addFieldText(LabelType.KEY, getAllLabelText(caseName, LabelType.KEY));
addFieldText(LabelType.KEY, getLabelText(caseName, LabelType.KEY, "1"));
//存储优先级信息
addFieldText(LabelType.RANK, getLabelText(caseName, LabelType.RANK, "1"));
@ -808,6 +892,8 @@ public class InformationCase extends Case {
clearFieldText();
// 存储case标签的name属性内容
String caseName = "addUploadFileCase";
//存储步骤信息
AtomicInteger index = new AtomicInteger(1);
//添加控件名称
wordMap.put(WordType.CONTROL_NAME.getName(), name);
@ -824,14 +910,14 @@ public class InformationCase extends Case {
//预览文件
if (isPreview) {
addFieldText(LabelType.STEP, getLabelText(caseName, LabelType.STEP, "11"));
addFieldText(LabelType.STEP, index.get(), getLabelText(caseName, LabelType.STEP, "11"));
//根据枚举类型选择相应的预期
switch (uploadFileType) {
case FILE:
addFieldText(LabelType.EXCEPT, getLabelText(caseName, LabelType.EXCEPT, "6"));
addFieldText(LabelType.EXCEPT, index.getAndIncrement(), getLabelText(caseName, LabelType.EXCEPT, "6"));
break;
case IMAGE:
addFieldText(LabelType.EXCEPT, getLabelText(caseName, LabelType.EXCEPT, "5"));
addFieldText(LabelType.EXCEPT, index.getAndIncrement(), getLabelText(caseName, LabelType.EXCEPT, "5"));
break;
default:
throw new IllegalArgumentException("不支持的类型:" + uploadFileType.getName());
@ -839,18 +925,18 @@ public class InformationCase extends Case {
}
//不上传文件
addFieldText(LabelType.STEP, getLabelText(caseName, LabelType.STEP, "1"));
addFieldText(LabelType.EXCEPT, getLabelText(caseName, LabelType.EXCEPT, isMust ? "2" : "1"));
addFieldText(LabelType.STEP, index.get(), getLabelText(caseName, LabelType.STEP, "1"));
addFieldText(LabelType.EXCEPT, index.getAndIncrement(), getLabelText(caseName, LabelType.EXCEPT, isMust ? "2" : "1"));
//删除文件用例
if (isDelete) {
//删除文件点保存
addFieldText(LabelType.STEP, getLabelText(caseName, LabelType.STEP, "3"));
addFieldText(LabelType.EXCEPT, getLabelText(caseName, LabelType.EXCEPT, isMust ? "2" : "1"));
addFieldText(LabelType.STEP, index.get(), getLabelText(caseName, LabelType.STEP, "3"));
addFieldText(LabelType.EXCEPT, index.getAndIncrement(), getLabelText(caseName, LabelType.EXCEPT, isMust ? "2" : "1"));
//删除文件再上传
addFieldText(LabelType.STEP, getLabelText(caseName, LabelType.STEP, "2"));
addFieldText(LabelType.EXCEPT, getLabelText(caseName, LabelType.EXCEPT, uploadFileType.equals(UploadFileType.IMAGE) ? "4" : "3"));
addFieldText(LabelType.STEP, index.get(), getLabelText(caseName, LabelType.STEP, "2"));
addFieldText(LabelType.EXCEPT, index.getAndIncrement(), getLabelText(caseName, LabelType.EXCEPT, uploadFileType.equals(UploadFileType.IMAGE) ? "4" : "3"));
}
//上传文件个数限制
@ -864,39 +950,39 @@ public class InformationCase extends Case {
wordMap.put(WordType.UPLOAD_MIN_LENGTH.getName(), String.valueOf(minLen));
//小于最小限制
addFieldText(LabelType.STEP, getLabelText(caseName, LabelType.STEP, "7"));
addFieldText(LabelType.EXCEPT, getLabelText(caseName, LabelType.EXCEPT, "2"));
addFieldText(LabelType.STEP, index.get(), getLabelText(caseName, LabelType.STEP, "7"));
addFieldText(LabelType.EXCEPT, index.getAndIncrement(), getLabelText(caseName, LabelType.EXCEPT, "2"));
//等于最小限制
addFieldText(LabelType.STEP, getLabelText(caseName, LabelType.STEP, "8"));
addFieldText(LabelType.EXCEPT, getLabelText(caseName, LabelType.EXCEPT, "1"));
addFieldText(LabelType.STEP, index.get(), getLabelText(caseName, LabelType.STEP, "8"));
addFieldText(LabelType.EXCEPT, index.getAndIncrement(), getLabelText(caseName, LabelType.EXCEPT, "1"));
} else if (minLen == 0 && maxLen != 0) {
//存储最大输入限制
wordMap.put(WordType.UPLOAD_MAX_LENGTH.getName(), String.valueOf(maxLen));
//大于最大限制
addFieldText(LabelType.STEP, getLabelText(caseName, LabelType.STEP, "9"));
addFieldText(LabelType.EXCEPT, getLabelText(caseName, LabelType.EXCEPT, "2"));
addFieldText(LabelType.STEP, index.get(), getLabelText(caseName, LabelType.STEP, "9"));
addFieldText(LabelType.EXCEPT, index.getAndIncrement(), getLabelText(caseName, LabelType.EXCEPT, "2"));
//等于最大限制
addFieldText(LabelType.STEP, getLabelText(caseName, LabelType.STEP, "10"));
addFieldText(LabelType.EXCEPT, getLabelText(caseName, LabelType.EXCEPT, "1"));
addFieldText(LabelType.STEP, index.get(), getLabelText(caseName, LabelType.STEP, "10"));
addFieldText(LabelType.EXCEPT, index.getAndIncrement(), getLabelText(caseName, LabelType.EXCEPT, "1"));
} else if (minLen != 0 && maxLen != 0) {
//若都不为0则将相应的内容进行存储且判断最大长度与最小长度是否传反若传反则调换顺序
wordMap.put(WordType.UPLOAD_MIN_LENGTH.getName(), String.valueOf(minLen < maxLen ? minLen : maxLen));
wordMap.put(WordType.UPLOAD_MAX_LENGTH.getName(), String.valueOf(minLen < maxLen ? maxLen : minLen));
//小于最小限制
addFieldText(LabelType.STEP, getLabelText(caseName, LabelType.STEP, "7"));
addFieldText(LabelType.EXCEPT, getLabelText(caseName, LabelType.EXCEPT, "2"));
addFieldText(LabelType.STEP, index.get(), getLabelText(caseName, LabelType.STEP, "7"));
addFieldText(LabelType.EXCEPT, index.getAndIncrement(), getLabelText(caseName, LabelType.EXCEPT, "2"));
//等于最小限制
addFieldText(LabelType.STEP, getLabelText(caseName, LabelType.STEP, "8"));
addFieldText(LabelType.EXCEPT, getLabelText(caseName, LabelType.EXCEPT, "1"));
addFieldText(LabelType.STEP, index.get(), getLabelText(caseName, LabelType.STEP, "8"));
addFieldText(LabelType.EXCEPT, index.getAndIncrement(), getLabelText(caseName, LabelType.EXCEPT, "1"));
//大于最大限制
addFieldText(LabelType.STEP, getLabelText(caseName, LabelType.STEP, "9"));
addFieldText(LabelType.EXCEPT, getLabelText(caseName, LabelType.EXCEPT, "2"));
addFieldText(LabelType.STEP, index.get(), getLabelText(caseName, LabelType.STEP, "9"));
addFieldText(LabelType.EXCEPT, index.getAndIncrement(), getLabelText(caseName, LabelType.EXCEPT, "2"));
//若最大最小限制相等则不添加等于最大限制
if (minLen != maxLen) {
//等于最大限制
addFieldText(LabelType.STEP, getLabelText(caseName, LabelType.STEP, "10"));
addFieldText(LabelType.EXCEPT, getLabelText(caseName, LabelType.EXCEPT, "1"));
addFieldText(LabelType.STEP, index.get(), getLabelText(caseName, LabelType.STEP, "10"));
addFieldText(LabelType.EXCEPT, index.getAndIncrement(), getLabelText(caseName, LabelType.EXCEPT, "1"));
}
} else {
//若均等于0则不进行处理
@ -907,12 +993,12 @@ public class InformationCase extends Case {
//存储大小限制
wordMap.put(WordType.FILE_SIZE.getName(), String.valueOf(fileSize));
//超过大小限制的用例
addFieldText(LabelType.STEP, getLabelText(caseName, LabelType.STEP, "4"));
addFieldText(LabelType.EXCEPT, getLabelText(caseName, LabelType.EXCEPT, "7"));
addFieldText(LabelType.STEP, index.get(), getLabelText(caseName, LabelType.STEP, "4"));
addFieldText(LabelType.EXCEPT, index.getAndIncrement(), getLabelText(caseName, LabelType.EXCEPT, "7"));
} else {
//超过大小限制的用例
addFieldText(LabelType.STEP, getLabelText(caseName, LabelType.STEP, "5"));
addFieldText(LabelType.EXCEPT, getLabelText(caseName, LabelType.EXCEPT, "8"));
addFieldText(LabelType.STEP, index.get(), getLabelText(caseName, LabelType.STEP, "5"));
addFieldText(LabelType.EXCEPT, index.getAndIncrement(), getLabelText(caseName, LabelType.EXCEPT, "8"));
}
//上传非限制格式文件
@ -922,15 +1008,18 @@ public class InformationCase extends Case {
fileRulesText += (fileRule.getName() + "");
}
wordMap.put(WordType.FILE_RULE.getName(), fileRulesText.substring(0, fileRulesText.length() - 1));
addFieldText(LabelType.STEP, getLabelText(caseName, LabelType.STEP, "6"));
addFieldText(LabelType.EXCEPT, getLabelText(caseName, LabelType.EXCEPT, "9"));
addFieldText(LabelType.STEP, index.get(), getLabelText(caseName, LabelType.STEP, "6"));
addFieldText(LabelType.EXCEPT, index.getAndIncrement(), getLabelText(caseName, LabelType.EXCEPT, "9"));
}
//----------------------------------------------------------------------
//存储前置条件信息
addFieldText(LabelType.PRECONDITION, getAllLabelText(caseName, LabelType.PRECONDITION));
index.set(1);
getAllLabelText(caseName, LabelType.PRECONDITION).forEach(text -> {
addFieldText(LabelType.PRECONDITION, index.getAndIncrement(), text);
});
//存储关键词信息
addFieldText(LabelType.KEY, getAllLabelText(caseName, LabelType.KEY));
addFieldText(LabelType.KEY, getLabelText(caseName, LabelType.KEY, "1"));
//存储优先级信息
addFieldText(LabelType.RANK, getLabelText(caseName, LabelType.RANK, "1"));
@ -947,18 +1036,21 @@ public class InformationCase extends Case {
private void textboxCommonCase(boolean isMust, boolean isRepeat, boolean isClear, InputRuleType... inputRuleTypes) {
// 存储case标签的name属性内容
String caseName = "textboxBasicCase";
//存储步骤信息
AtomicInteger index = new AtomicInteger(1);
//转换输入限制为集合类型
List<InputRuleType> inputRules = Arrays.asList(inputRuleTypes);
//不填写或只输入空格
addFieldText(LabelType.STEP, getLabelText(caseName, LabelType.STEP, "1"));
addFieldText(LabelType.STEP, index.get(), getLabelText(caseName, LabelType.STEP, "1"));
//根据是否必填来判断填入成功或失败预期
addFieldText(LabelType.EXCEPT, getLabelText(caseName, LabelType.EXCEPT, isMust ? "2" : "1"));
addFieldText(LabelType.EXCEPT, index.getAndIncrement(), getLabelText(caseName, LabelType.EXCEPT, isMust ? "2" : "1"));
//填写特殊字符或HTML代码
addFieldText(LabelType.STEP, getLabelText(caseName, LabelType.STEP, "2"));
addFieldText(LabelType.STEP, index.get(), getLabelText(caseName, LabelType.STEP, "2"));
//根据是否存在输入
addFieldText(LabelType.EXCEPT, getLabelText(caseName, LabelType.EXCEPT, inputRules.size() == 0 || inputRules.contains(InputRuleType.SPE) ? "1" : "2"));
addFieldText(LabelType.EXCEPT, index.getAndIncrement(), getLabelText(caseName, LabelType.EXCEPT, inputRules.size() == 0 || inputRules.contains(InputRuleType.SPE) ? "1" : "2"));
//输入非限制的字符
if (inputRules.size() != 0) {
@ -967,16 +1059,16 @@ public class InformationCase extends Case {
inputRuleText += (inputRule.getName() + "");
}
wordMap.put(WordType.INPUT_RULE.getName(), inputRuleText.substring(0, inputRuleText.length() - 1));
addFieldText(LabelType.STEP, getLabelText(caseName, LabelType.STEP, "3"));
addFieldText(LabelType.EXCEPT, getLabelText(caseName, LabelType.EXCEPT, "2"));
addFieldText(LabelType.STEP, index.get(), getLabelText(caseName, LabelType.STEP, "3"));
addFieldText(LabelType.EXCEPT, index.getAndIncrement(), getLabelText(caseName, LabelType.EXCEPT, "2"));
}
//清空输入的内容
if (isClear) {
//不填写或只输入空格
addFieldText(LabelType.STEP, getLabelText(caseName, LabelType.STEP, "13"));
addFieldText(LabelType.STEP, index.get(), getLabelText(caseName, LabelType.STEP, "13"));
//根据是否必填来判断填入成功或失败预期
addFieldText(LabelType.EXCEPT, getLabelText(caseName, LabelType.EXCEPT, isMust ? "4" : "3"));
addFieldText(LabelType.EXCEPT, index.getAndIncrement(), getLabelText(caseName, LabelType.EXCEPT, isMust ? "4" : "3"));
}
}
@ -989,30 +1081,32 @@ public class InformationCase extends Case {
private void dateboxCommonCase(boolean isMust, boolean isInput, boolean isClear) {
// 存储case标签的name属性内容
String caseName = "addDateCase";
//存储步骤信息
AtomicInteger index = new AtomicInteger(1);
//不填写
addFieldText(LabelType.STEP, getLabelText(caseName, LabelType.STEP, "1"));
addFieldText(LabelType.STEP, index.get(), getLabelText(caseName, LabelType.STEP, "1"));
//根据是否必填来判断填入成功或失败预期
addFieldText(LabelType.EXCEPT, getLabelText(caseName, LabelType.EXCEPT, isMust ? "2" : "1"));
addFieldText(LabelType.EXCEPT, index.getAndIncrement(), getLabelText(caseName, LabelType.EXCEPT, isMust ? "2" : "1"));
//选择当前时间
addFieldText(LabelType.STEP, getLabelText(caseName, LabelType.STEP, "2"));
addFieldText(LabelType.EXCEPT, getLabelText(caseName, LabelType.EXCEPT, isMust ? "2" : "1"));
addFieldText(LabelType.STEP, index.get(), getLabelText(caseName, LabelType.STEP, "2"));
addFieldText(LabelType.EXCEPT, index.getAndIncrement(), getLabelText(caseName, LabelType.EXCEPT, isMust ? "2" : "1"));
//选择时间后清除时间
if (isClear) {
addFieldText(LabelType.STEP, getLabelText(caseName, LabelType.STEP, "3"));
addFieldText(LabelType.EXCEPT, getLabelText(caseName, LabelType.EXCEPT, isMust ? "2" : "1"));
addFieldText(LabelType.STEP, index.get(), getLabelText(caseName, LabelType.STEP, "3"));
addFieldText(LabelType.EXCEPT, index.getAndIncrement(), getLabelText(caseName, LabelType.EXCEPT, isMust ? "2" : "1"));
}
//手动输入时间
if (isInput) {
//输入正确格式
addFieldText(LabelType.STEP, getLabelText(caseName, LabelType.STEP, "4"));
addFieldText(LabelType.EXCEPT, getLabelText(caseName, LabelType.EXCEPT, "1"));
addFieldText(LabelType.STEP, index.get(), getLabelText(caseName, LabelType.STEP, "4"));
addFieldText(LabelType.EXCEPT, index.getAndIncrement(), getLabelText(caseName, LabelType.EXCEPT, "1"));
//输入不正确的格式
addFieldText(LabelType.STEP, getLabelText(caseName, LabelType.STEP, "5"));
addFieldText(LabelType.EXCEPT, getLabelText(caseName, LabelType.EXCEPT, "2"));
addFieldText(LabelType.STEP, index.get(), getLabelText(caseName, LabelType.STEP, "5"));
addFieldText(LabelType.EXCEPT, index.getAndIncrement(), getLabelText(caseName, LabelType.EXCEPT, "2"));
}
}

View File

@ -10,7 +10,7 @@ package pres.auxiliary.work.n.tcase;
* @since JDK 12
*
*/
enum LabelType {
public enum LabelType {
/**
* 用例标签
*/

View File

@ -77,6 +77,11 @@ public class TestCaseWrite {
*/
private HashMap<String, String> replaceWordMap = new HashMap<>(16);
/**
* 用于存储与测试用例生成类关联的字段参数1为用例文件中的字段参数2为测试用例生成方法中的字段
*/
private HashMap<String, String> relevanceMap = new HashMap<>(16);
/**
* 用于存储数据有效性的内容
*/
@ -225,7 +230,7 @@ public class TestCaseWrite {
*/
public void setFieldValue(String field, String content) {
// 为保证在写用例的时候也能生效故将值设置进入fieldMap
addContent(field, content);
addContent(field, false, content);
// 先将值设置入fieldMap中可以保证field字段是存在于fieldMap中以减少此处再做判断
// 将字段内容写入caseValueMap
@ -242,6 +247,23 @@ public class TestCaseWrite {
word = WORD_SIGN + word + WORD_SIGN;
replaceWordMap.put(word, replactWord);
}
/**
* 用于将测试用例文件模板中的字段名与测试用例生成类继承自{@link Case}的测试用例生成类
* 的字段进行关联通过该方法设置关联字段后可将生成的测试用例写入到测试用例文件中
* @param field 测试用例文件字段
* @param caseLabel 测试用例生成方法的字段
* @throws LabelNotFoundException 当在sheet标签中查不到相应的单元格id不存在时抛出的异常
*/
public void relevanceCase(String field, String caseLabel) {
//判断字段是否存在若不存在则抛出异常
if (!fieldMap.containsKey(field)) {
throw new LabelNotFoundException("当前sheet不存在的标签id" + field);
}
//添加字段
relevanceMap.put(field, caseLabel);
}
/**
* 向用例中添加步骤可传入多个参数每一个参数表示一个步骤通过该方法传入后将自动对数据进行编号和换行
@ -260,7 +282,7 @@ public class TestCaseWrite {
steps[i] = ((i + 1) + "." + steps[i]);
}
return addContent(FieldType.STEP.getValue(), steps);
return addContent(FieldType.STEP.getValue(), false, steps);
}
/**
@ -280,7 +302,7 @@ public class TestCaseWrite {
excepts[i] = ((i + 1) + "." + excepts[i]);
}
return addContent(FieldType.EXPECT.getValue(), excepts);
return addContent(FieldType.EXPECT.getValue(), false, excepts);
}
/**
@ -295,12 +317,7 @@ public class TestCaseWrite {
* @return 类本身以方便链式编码
*/
public TestCaseWrite addPrecondition(String... preconditions) {
// 为每一段添加标号
for (int i = 0; i < preconditions.length; i++) {
preconditions[i] = ((i + 1) + "." + preconditions[i]);
}
return addContent(FieldType.PRECONDITION.getValue(), preconditions);
return addContent(FieldType.PRECONDITION.getValue(), true, preconditions);
}
/**
@ -315,7 +332,7 @@ public class TestCaseWrite {
* @return 类本身以方便链式编码
*/
public TestCaseWrite addTitle(String title) {
return addContent(FieldType.TITLE.getValue(), title);
return addContent(FieldType.TITLE.getValue(), false, title);
}
/**
@ -342,9 +359,9 @@ public class TestCaseWrite {
text = this.rank[this.rank.length - 1];
}
return addContent(FieldType.RANK.getValue(), text);
return addContent(FieldType.RANK.getValue(), false, text);
} else {
return addContent(FieldType.RANK.getValue(), String.valueOf(rank));
return addContent(FieldType.RANK.getValue(), false, String.valueOf(rank));
}
}
@ -360,7 +377,7 @@ public class TestCaseWrite {
* @return 类本身以方便链式编码
* @throws LabelNotFoundException 当在sheet标签中查不到相应的单元格id不存在时抛出的异常
*/
public TestCaseWrite addContent(String field, String... contents) {
public TestCaseWrite addContent(String field, boolean hasindex, String... contents) {
// 判断字段是否存在若不存在则抛出异常
if (!fieldMap.containsKey(field)) {
throw new LabelNotFoundException("当前sheet不存在的标签id" + field);
@ -370,16 +387,42 @@ public class TestCaseWrite {
for (String word : replaceWordMap.keySet()) {
// 查找所有的内容并将特殊词语进行替换
for (int i = 0; i < contents.length; i++) {
contents[i] = contents[i].replaceAll(word, replaceWordMap.get(word));
contents[i] = hasindex ? (String.valueOf(i + 1) + ".") : "" + contents[i].replaceAll(word, replaceWordMap.get(word));
}
}
// 将字段内容写入fieldMap
fieldMap.get(field).content = contents;
// fieldMap.put(field, contents);
return this;
}
/**
* 用于将生成测试用例方法继承自{@link Case}类的方法所成成的测试用例添加到测试用例文件中
* @param testCase 测试用例生成方法
* @return 类本身
*/
public TestCaseWrite addCase(Case testCase) {
//获取用例内容
HashMap<String, ArrayList<String>> labelMap = testCase.getFieldTextMap();
//遍历relevanceMap将用例字段内容写入到xml中
relevanceMap.forEach((field, label) -> {
//若字段为优先级字段则进行特殊处理
if (FieldType.RANK.getValue().equals(field)) {
//添加优先级字段若可以转换则使用内置的添加优先级方法若不能转换则直接存储
try {
addRank(Integer.valueOf(labelMap.get(label).get(0)));
} catch (Exception e) {
addContent(field, false, labelMap.get(label).get(0));
}
} else {
addContent(field, false, labelMap.get(label).toArray(new String[] {}));
}
});
return this;
}
/**
* 用于结束一条用例写作的标志调用该方法后将结束一条用例的编写 该方法以下的添加用例内容的方法均为编辑另一条用例
@ -423,7 +466,7 @@ public class TestCaseWrite {
if (caseValueMap != null && caseValueMap.size() != 0) {
caseValueMap.forEach((field, content) -> {
try {
addContent(field, content);
addContent(field, false, content);
} catch (LabelNotFoundException e) {
}
});

View File

@ -1,7 +1,6 @@
package pres.auxiliary.work.testcase;
import java.io.File;
import java.util.concurrent.atomic.AtomicInteger;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeClass;
@ -31,10 +30,9 @@ InformationCase ic = new InformationCase(new File("ConfigurationFiles/CaseConfig
System.out.println("------------------------------");
ic.getFieldTextMap().forEach((k, v) -> {
//可生成序号类封装了普通的自增等操作
AtomicInteger commitCount = new AtomicInteger(1);
System.out.println(k + ":");
v.forEach(s -> {
System.out.println(commitCount.getAndIncrement() + "." + s);
System.out.println(s);
});
});
}

View File

@ -3,7 +3,6 @@ package pres.auxiliary.work.testcase;
import java.io.File;
import java.io.IOException;
import java.lang.reflect.Method;
import java.util.Arrays;
import org.dom4j.DocumentException;
import org.testng.annotations.AfterClass;
@ -13,6 +12,8 @@ import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import pres.auxiliary.work.n.tcase.FieldType;
import pres.auxiliary.work.n.tcase.InformationCase;
import pres.auxiliary.work.n.tcase.LabelType;
import pres.auxiliary.work.n.tcase.MarkColorsType;
import pres.auxiliary.work.n.tcase.TestCaseTemplet;
import pres.auxiliary.work.n.tcase.TestCaseWrite;
@ -62,6 +63,12 @@ public class WriteTestCaseTest {
wtc.setPresupposeField(FieldType.RANK, "优先级");
wtc.setPresupposeField(FieldType.STEP, "步骤");
wtc.setPresupposeField(FieldType.TITLE, "标题");
wtc.relevanceCase("步骤", LabelType.STEP.getName());
wtc.relevanceCase("预期", LabelType.EXCEPT.getName());
wtc.relevanceCase("优先级", LabelType.RANK.getName());
wtc.relevanceCase("前置条件", LabelType.PRECONDITION.getName());
wtc.relevanceCase("标题", LabelType.TITLE.getName());
}
/**
@ -73,7 +80,7 @@ public class WriteTestCaseTest {
public void openFolder() throws IOException {
wtc.writeFile();
System.out.println("-".repeat(20));
System.out.println("优先级:");
// System.out.println("优先级:");
// Arrays.stream(wtc.getRank()).forEach(System.out::println);
// wtc.getCaseXml();
// java.awt.Desktop.getDesktop().open(wtc.getCaseXml());
@ -83,16 +90,16 @@ public class WriteTestCaseTest {
@BeforeMethod
public void addContent(Method method) {
System.out.println("=======正在运行:" + method.getName() + "=======");
wtc.addRank(1);
wtc.addStep("步骤1", "步骤2", "步骤3");
wtc.addTitle("这是标题");
wtc.addPrecondition("前置条件1", "前置条件2", "前置条件3");
wtc.addExcept("预期1", "预期2", "预期3");
wtc.addContent("目的", "这是目的1", "这是目的2");
wtc.addContent("模块", "这是模块");
wtc.addContent("状态", "这是状态");
wtc.addContent("项目", "这是项目");
wtc.addContent("设计者", "这是设计者");
// wtc.addRank(1);
// wtc.addStep("步骤1", "步骤2", "步骤3");
// wtc.addTitle("这是标题");
// wtc.addPrecondition("前置条件1", "前置条件2", "前置条件3");
// wtc.addExcept("预期1", "预期2", "预期3");
// wtc.addContent("目的", false, "这是目的1", "这是目的2");
// wtc.addContent("模块", false, "这是模块");
// wtc.addContent("状态", false, "这是状态");
// wtc.addContent("项目", false, "这是项目");
// wtc.addContent("设计者", false, "这是设计者");
}
/**
@ -108,7 +115,7 @@ public class WriteTestCaseTest {
*/
@Test
public void addContentTest() {
wtc.addContent("标题", "这是标题").addContent("目的", "这是目的");
wtc.addContent("标题", false, "这是标题").addContent("目的", false, "这是目的");
}
/**
@ -156,6 +163,16 @@ public class WriteTestCaseTest {
wtc.addPrecondition("前置条件1", "前置条件2", "前置条件3");
}
/**
* 测试{@link TestCaseWrite#addCase(pres.auxiliary.work.n.tcase.Case)}方法
*/
@Test
public void addCaseTest() {
InformationCase ic = new InformationCase(new File("ConfigurationFiles/CaseConfigurationFile/CaseTemplet/AddInformation.xml"));
wtc.addCase(ic.addRadioButtonCase("测试控件")).end();
}
/**
* 测试{@link TestCaseWrite#addTitle(String)}方法
*/
@ -245,7 +262,7 @@ public class WriteTestCaseTest {
public void markStepAndExceptTest() {
wtc.end().markStepAndExcept(2, MarkColorsType.RED);
}
/**
* 综合测试标记方法
*/