diff --git a/lib/mo-tester-1.0-SNAPSHOT.jar b/lib/mo-tester-1.0-SNAPSHOT.jar index 0c47ab1c5..ecdd4ab09 100644 Binary files a/lib/mo-tester-1.0-SNAPSHOT.jar and b/lib/mo-tester-1.0-SNAPSHOT.jar differ diff --git a/src/main/java/io/mo/Tester.java b/src/main/java/io/mo/Tester.java index 35daa1415..f5b895d46 100755 --- a/src/main/java/io/mo/Tester.java +++ b/src/main/java/io/mo/Tester.java @@ -33,15 +33,31 @@ public static void main(String[] args){ //get path if (arg.startsWith("path")) { path = arg.split("=")[1]; + File caseFile = new File(path); + String srcPath = null; + if(caseFile.getAbsolutePath().contains(COMMON.CASES_DIR)) { + srcPath = caseFile.getAbsolutePath(); + srcPath = srcPath.replace(COMMON.CASES_DIR,COMMON.RESOURCE_DIR); + srcPath = srcPath.substring(0,srcPath.indexOf(COMMON.RESOURCE_DIR)+COMMON.RESOURCE_DIR.length()); + } + COMMON.RESOURCE_PATH = srcPath; } //get method if (arg.startsWith("method")) { + if(!arg.contains("=")){ + LOG.error("The format of para[method] is not valid,please check......"); + System.exit(1); + } method = arg.split("=")[1]; } //get sucess rate if (arg.startsWith("rate")) { + if(!arg.contains("=")){ + LOG.error("The format of para[rate] is not valid,please check......"); + System.exit(1); + } rate = Integer.parseInt(arg.split("=")[1]); } @@ -52,16 +68,29 @@ public static void main(String[] args){ //get includes if (arg.startsWith("include")) { + if(!arg.contains("=")){ + LOG.error("The format of para[include] is not valid,please check......"); + System.exit(1); + } includes = arg.split("=")[1].split(","); } //get excludes if (arg.startsWith("exclude")) { + if(!arg.contains("=")){ + LOG.error("The format of para[include] is not valid,please check......"); + System.exit(1); + } excludes = arg.split("=")[1].split(","); } //get resource path if (arg.startsWith("resource")) { + if(!arg.contains("=")){ + LOG.error("The format of para[resource] is not valid,please check......"); + System.exit(1); + } + COMMON.RESOURCE_PATH = arg.split("=")[1]; } diff --git a/src/main/java/io/mo/db/Executor.java b/src/main/java/io/mo/db/Executor.java index 2806f499b..daf941350 100755 --- a/src/main/java/io/mo/db/Executor.java +++ b/src/main/java/io/mo/db/Executor.java @@ -81,7 +81,7 @@ public static void run(TestScript script){ "[ACTUAL RESULT]:\n" + command.getTestResult().getExpResult() + "\n"); LOG.error("[" + script.getFileName() + "][row:" + command.getPosition() + "][" + command.getCommand().trim() + "] was executed failed"); LOG.error("[EXPECT RESULT]:\n" + command.getTestResult().getExpResult()); - LOG.error("[ACTUAL RESULT]:\n" + command.getTestResult().getExpResult()); + LOG.error("[ACTUAL RESULT]:\n" + command.getTestResult().getActResult()); continue; } @@ -138,7 +138,7 @@ public static void run(TestScript script){ "[ACTUAL RESULT]:\n" + command.getTestResult().getExpResult() + "\n"); LOG.error("[" + script.getFileName() + "][row:" + command.getPosition() + "][" + command.getCommand().trim() + "] was executed failed"); LOG.error("[EXPECT RESULT]:\n" + command.getTestResult().getExpResult()); - LOG.error("[ACTUAL RESULT]:\n" + command.getTestResult().getExpResult()); + LOG.error("[ACTUAL RESULT]:\n" + command.getTestResult().getActResult()); continue; } diff --git a/src/main/java/io/mo/result/RSCell.java b/src/main/java/io/mo/result/RSCell.java index 610ed713c..e4f59c858 100644 --- a/src/main/java/io/mo/result/RSCell.java +++ b/src/main/java/io/mo/result/RSCell.java @@ -51,6 +51,11 @@ public boolean equals(RSCell cell){ //precision toleration code String v1 = (String)this.value; String v2 = (String)cell.getValue(); + + //if one is NULL,return false + if(v1.equalsIgnoreCase("null") || v2.equalsIgnoreCase("null")) + return false; + if(cell.type == Types.FLOAT || cell.type == Types.REAL || @@ -58,13 +63,20 @@ public boolean equals(RSCell cell){ cell.type == Types.DECIMAL|| cell.type == Types.BIGINT || (cell.type == Types.VARCHAR && isNumeric(v1) &&isNumeric(v2))) { + BigDecimal bd1 = BigDecimal.valueOf(Double.valueOf(v1)).stripTrailingZeros(); BigDecimal bd2 = BigDecimal.valueOf(Double.valueOf(v2)).stripTrailingZeros(); //System.out.println("bd1 = " + bd1); //System.out.println("bd2 = " + bd2); + + if(bd1.compareTo(bd2) == 0) return true; + else{ + if(bd1.equals(BigDecimal.ZERO) || bd2.equals(BigDecimal.ZERO)) + return false; + } //round to one with samll scale, and compare int scal1 = bd1.scale(); @@ -90,7 +102,7 @@ public boolean equals(RSCell cell){ LOG.debug("value[" + v1 +"] and value[" + v2 +"] match the scale tolerable error"); return true; } - + error = error.divide(bd1,BigDecimal.ROUND_HALF_UP); toleration = BigDecimal.valueOf(COMMON.INT_TOLERABLE_ERROR); //if error beteen bd1 and bd2 divided bd1 or db2 is less than INT_TOLERABLE_ERROR(0.0.000000000000001),return true;