Skip to content

Commit

Permalink
Merge pull request #343 from caofengbin/feature/add_assert_not_equal
Browse files Browse the repository at this point in the history
实现断言验证(不相等)的agent逻辑,并丰富另外三个断言类型的输出
  • Loading branch information
ZhouYixun authored May 17, 2023
2 parents d93d467 + 0c887b0 commit 22ecc94
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -501,19 +501,26 @@ public void locationMode(HandleContext handleContext, boolean enable) {
}

public void asserts(HandleContext handleContext, String actual, String expect, String type) {
handleContext.setDetail("真实值: " + actual + " 期望值: " + expect);
handleContext.setStepDes("");
try {
switch (type) {
case "assertEquals" -> {
handleContext.setDetail("真实值: " + actual + " 期望等于: " + expect);
handleContext.setStepDes("断言验证(相等)");
assertEquals(actual, expect);
}
case "assertNotEquals" -> {
handleContext.setDetail("真实值: " + actual + " 期望不等于: " + expect);
handleContext.setStepDes("断言验证(不相等)");
assertNotEquals(actual, expect);
}
case "assertTrue" -> {
handleContext.setDetail("真实值: " + actual + " 期望包含: " + expect);
handleContext.setStepDes("断言验证(包含)");
assertTrue(actual.contains(expect));
}
case "assertNotTrue" -> {
handleContext.setDetail("真实值: " + actual + " 期望不包含: " + expect);
handleContext.setStepDes("断言验证(不包含)");
assertFalse(actual.contains(expect));
}
Expand Down Expand Up @@ -2170,7 +2177,7 @@ public void runStep(JSONObject stepJSON, HandleContext handleContext) throws Thr
case "locationMode" -> locationMode(handleContext, step.getBoolean("content"));
case "keyCode" -> keyCode(handleContext, step.getString("content"));
case "keyCodeSelf" -> keyCode(handleContext, step.getInteger("content"));
case "assertEquals", "assertTrue", "assertNotTrue" -> {
case "assertEquals", "assertNotEquals", "assertTrue", "assertNotTrue" -> {
String actual = TextHandler.replaceTrans(step.getString("text"), globalParams);
String expect = TextHandler.replaceTrans(step.getString("content"), globalParams);
asserts(handleContext, actual, expect, step.getString("stepType"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -389,19 +389,26 @@ public void unLock(HandleContext handleContext) {
}

public void asserts(HandleContext handleContext, String actual, String expect, String type) {
handleContext.setDetail("真实值: " + actual + " 期望值: " + expect);
handleContext.setStepDes("");
try {
switch (type) {
case "assertEquals" -> {
handleContext.setDetail("真实值: " + actual + " 期望等于: " + expect);
handleContext.setStepDes("断言验证(相等)");
assertEquals(actual, expect);
}
case "assertNotEquals" -> {
handleContext.setDetail("真实值: " + actual + " 期望不等于: " + expect);
handleContext.setStepDes("断言验证(不相等)");
assertNotEquals(actual, expect);
}
case "assertTrue" -> {
handleContext.setDetail("真实值: " + actual + " 期望包含: " + expect);
handleContext.setStepDes("断言验证(包含)");
assertTrue(actual.contains(expect));
}
case "assertNotTrue" -> {
handleContext.setDetail("真实值: " + actual + " 期望不包含: " + expect);
handleContext.setStepDes("断言验证(不包含)");
assertFalse(actual.contains(expect));
}
Expand Down Expand Up @@ -1488,7 +1495,7 @@ public void runStep(JSONObject stepJSON, HandleContext handleContext) throws Thr
case "lock" -> lock(handleContext);
case "unLock" -> unLock(handleContext);
case "keyCode" -> keyCode(handleContext, step.getString("content"));
case "assertEquals", "assertTrue", "assertNotTrue" -> {
case "assertEquals", "assertNotEquals", "assertTrue", "assertNotTrue" -> {
String actual = TextHandler.replaceTrans(step.getString("text"), globalParams);
String expect = TextHandler.replaceTrans(step.getString("content"), globalParams);
asserts(handleContext, actual, expect, step.getString("stepType"));
Expand Down

0 comments on commit 22ecc94

Please sign in to comment.