aboutsummaryrefslogtreecommitdiff
path: root/core/src/main/java/com/google/common/truth/TruthJUnit.java
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/main/java/com/google/common/truth/TruthJUnit.java')
-rw-r--r--core/src/main/java/com/google/common/truth/TruthJUnit.java31
1 files changed, 10 insertions, 21 deletions
diff --git a/core/src/main/java/com/google/common/truth/TruthJUnit.java b/core/src/main/java/com/google/common/truth/TruthJUnit.java
index 3c70d887..ad82efb2 100644
--- a/core/src/main/java/com/google/common/truth/TruthJUnit.java
+++ b/core/src/main/java/com/google/common/truth/TruthJUnit.java
@@ -16,7 +16,7 @@
package com.google.common.truth;
import com.google.common.annotations.GwtIncompatible;
-import org.junit.internal.AssumptionViolatedException;
+import org.junit.AssumptionViolatedException;
/**
* Provides a way to use Truth to perform JUnit "assumptions." An assumption is a check that, if
@@ -41,20 +41,17 @@ import org.junit.internal.AssumptionViolatedException;
* @author Christian Gruber (cgruber@israfil.net)
*/
@GwtIncompatible("JUnit4")
+@J2ktIncompatible
public final class TruthJUnit {
- private static final FailureStrategy THROW_ASSUMPTION_ERROR =
- new FailureStrategy() {
- @Override
- public void fail(AssertionError failure) {
- ThrowableAssumptionViolatedException assumptionViolated =
- new ThrowableAssumptionViolatedException(failure.getMessage(), failure.getCause());
- assumptionViolated.setStackTrace(failure.getStackTrace());
- throw assumptionViolated;
- }
- };
-
+ @SuppressWarnings("ConstantCaseForConstants") // Despite the "Builder" name, it's not mutable.
private static final StandardSubjectBuilder ASSUME =
- StandardSubjectBuilder.forCustomFailureStrategy(THROW_ASSUMPTION_ERROR);
+ StandardSubjectBuilder.forCustomFailureStrategy(
+ failure -> {
+ AssumptionViolatedException assumptionViolated =
+ new AssumptionViolatedException(failure.getMessage(), failure.getCause());
+ assumptionViolated.setStackTrace(failure.getStackTrace());
+ throw assumptionViolated;
+ });
/**
* Begins a call chain with the fluent Truth API. If the check made by the chain fails, it will
@@ -64,13 +61,5 @@ public final class TruthJUnit {
return ASSUME;
}
- // TODO(diamondm): remove this and use org.junit.AssumptionViolatedException once we're on v4.12
- private static class ThrowableAssumptionViolatedException extends AssumptionViolatedException {
- public ThrowableAssumptionViolatedException(String message, Throwable throwable) {
- super(message);
- if (throwable != null) initCause(throwable);
- }
- }
-
private TruthJUnit() {}
}