Skip to content

Commit

Permalink
[fix] fix show command handler
Browse files Browse the repository at this point in the history
  • Loading branch information
liubingmx committed Mar 29, 2024
1 parent 5a5b2cd commit 38e701d
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,11 @@ private void showResult() {
}
}
System.out.println();
if (lastRunResult.getTotalTestCount() != lastRunResult.getStarted()) {
return;
}
log("--------------------------------- Summary ---------------------------------");
log("RUN %s",lastRunResult.getUniqueId());
log("RUN %s", lastRunResult.getUniqueId());
log("Result -- started:%d -- succeeded: %d -- failed: %d -- skipped: %d -- cost: %d ms",
lastRunResult.getStarted(), lastRunResult.getSucceeded(), lastRunResult.getFailed(),
lastRunResult.getSkipped(), lastRunResult.getCost());
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/cn/net/fasttest/runner/RunnerFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@ public static TestRunner getRunner(String methodName, Class<?> clazz) {
return runnerMap.get(runnerName);
}
}
Method[] methods = clazz.getMethods();
for (Method method : methods) {
testAnnotation = method.getAnnotation(testAnnotationClazz);
if (Objects.nonNull(testAnnotation)) {
return runnerMap.get(runnerName);
}
}
} catch (ClassNotFoundException e) {
continue;
}catch (NoSuchMethodException | ClassCastException e){
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/cn/net/fasttest/runner/TestRunResult.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,21 @@ public class TestRunResult {
private String state;
private String displayName;
private long cost;

private long totalTestCount;
private long started;
private long succeeded;
private long failed;
private long skipped;

public long getTotalTestCount() {
return totalTestCount;
}

public void setTotalTestCount(long totalTestCount) {
this.totalTestCount = totalTestCount;
}

public void setCost(long cost) {
this.cost = cost;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,14 @@ public void executionFinished(TestIdentifier testIdentifier, TestExecutionResult
TestRunResult testRunResult = new TestRunResult();
testRunResult.setState(testExecutionResult.getStatus().name());
testRunResult.setDisplayName(testIdentifier.getDisplayName());
testRunResult.setUniqueId(clazz.getName() + "#" + method);
testRunResult.setUniqueId(method != null ? clazz.getName() + "#" + method : clazz.getName());
testRunResult.setThrowable(throwable.orElse(null));
testRunResult.setCost(System.currentTimeMillis() - summary.getTimeStarted());
testRunResult.setFailed(summary.getTestsFailedCount());
testRunResult.setSucceeded(summary.getTestsSucceededCount());
testRunResult.setSkipped(summary.getTestsSkippedCount());
testRunResult.setStarted(summary.getTestsStartedCount());
testRunResult.setTotalTestCount(summary.getTestsFoundCount());
EventBus.publishEvent(new FastSpringTestEvent(EventEnum.RUN_TESTCASE, testRunResult));
}
}

0 comments on commit 38e701d

Please sign in to comment.