Skip to content

Commit

Permalink
[x2fDvuKu] improve output for failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nadja-muller committed Oct 4, 2023
1 parent f0020dc commit b1c197c
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions test-utils/src/main/java/apoc/util/TransactionTestUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
public class TransactionTestUtil {
public static final String TRANSACTION_LIST = "SHOW TRANSACTIONS";
public static final long DEFAULT_TIMEOUT = 10L;
public static final double MARGIN = 1.2;

public static void checkTerminationGuard(GraphDatabaseService db, String query) {
checkTerminationGuard(db, query, emptyMap());
Expand Down Expand Up @@ -80,9 +81,12 @@ public static void lastTransactionChecks(GraphDatabaseService db, String query,
}

public static void checkTransactionTime(long timeout, long timePassed) {
timePassed = (System.currentTimeMillis() - timePassed) / 1000;
assertTrue("The transaction hasn't been terminated before the timeout time, but after " + timePassed + " seconds",
timePassed <= timeout);
double timePassedDouble = (System.currentTimeMillis() - timePassed) / 1000d;
double timeoutWithMargin = timeout * MARGIN;

assertTrue("The transaction hasn't been terminated before the given timeout time (" + timeoutWithMargin
+ "), but after " + timePassedDouble + " seconds",
timePassedDouble <= timeout * timeoutWithMargin);
}

public static void checkTransactionNotInList(GraphDatabaseService db, String query) {
Expand Down

0 comments on commit b1c197c

Please sign in to comment.