mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-08-16 10:20:32 -04:00
Bisq
This commit is contained in:
commit
8a38081c04
2800 changed files with 344130 additions and 0 deletions
58
apitest/src/test/java/bisq/apitest/JUnitHelper.java
Normal file
58
apitest/src/test/java/bisq/apitest/JUnitHelper.java
Normal file
|
@ -0,0 +1,58 @@
|
|||
package bisq.apitest;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import org.junit.runner.Description;
|
||||
import org.junit.runner.JUnitCore;
|
||||
import org.junit.runner.Result;
|
||||
import org.junit.runner.notification.Failure;
|
||||
import org.junit.runner.notification.RunListener;
|
||||
|
||||
import static java.lang.String.format;
|
||||
|
||||
@Slf4j
|
||||
public class JUnitHelper {
|
||||
|
||||
private static boolean allPass;
|
||||
|
||||
public static void runTests(Class<?>... testClasses) {
|
||||
JUnitCore jUnitCore = new JUnitCore();
|
||||
jUnitCore.addListener(new RunListener() {
|
||||
public void testStarted(Description description) {
|
||||
log.info("{}", description);
|
||||
}
|
||||
|
||||
public void testIgnored(Description description) {
|
||||
log.info("Ignored {}", description);
|
||||
}
|
||||
|
||||
public void testFailure(Failure failure) {
|
||||
log.error("Failed {}", failure.getTrace());
|
||||
}
|
||||
});
|
||||
Result result = jUnitCore.run(testClasses);
|
||||
printTestResults(result);
|
||||
}
|
||||
|
||||
public static boolean allTestsPassed() {
|
||||
return allPass;
|
||||
}
|
||||
|
||||
private static void printTestResults(Result result) {
|
||||
log.info("Total tests: {}, Failed: {}, Ignored: {}",
|
||||
result.getRunCount(),
|
||||
result.getFailureCount(),
|
||||
result.getIgnoreCount());
|
||||
|
||||
if (result.wasSuccessful()) {
|
||||
log.info("All {} tests passed", result.getRunCount());
|
||||
allPass = true;
|
||||
} else if (result.getFailureCount() > 0) {
|
||||
log.error("{} test(s) failed", result.getFailureCount());
|
||||
result.getFailures().iterator().forEachRemaining(f -> log.error(format("%s.%s()%n\t%s",
|
||||
f.getDescription().getTestClass().getName(),
|
||||
f.getDescription().getMethodName(),
|
||||
f.getTrace())));
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue