Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
Catch JUnit assertion error, makes using JUnit Assertions easier
Browse files Browse the repository at this point in the history
  • Loading branch information
robotgryphon committed Sep 12, 2021
1 parent f7c43d1 commit 6fc3581
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

import com.alcatrazescapee.mcjunitlib.framework.mod.ForgeEventHandler;
import org.objectweb.asm.Type;
import org.opentest4j.AssertionFailedError;

/**
* Main handler for integration tests
Expand Down Expand Up @@ -132,6 +133,12 @@ private static IntegrationTestRunner createIntegrationTest(String modId, ModFile
LOGGER.debug("Error", e);
helper.fail("Reflection Error: " + e.getMessage());
}
catch(AssertionFailedError a) {
LOGGER.debug("Assertion Error: " + a.getMessage());
helper.fail("Assertion Error: " + a.getMessage());
if(a.isExpectedDefined() && a.isActualDefined())
helper.fail("Expected <" + a.getExpected() + "> but got <" + a.getActual() + ">.");
}
}, testMethodName, templateName, typedAnnotation.refreshTicks(), typedAnnotation.timeoutTicks());
}
catch (ClassNotFoundException | NoSuchMethodException | InstantiationException | IllegalAccessException e)
Expand Down

0 comments on commit 6fc3581

Please sign in to comment.