Interface Java6StandardSoftAssertionsProvider
-
- All Superinterfaces:
AfterAssertionErrorCollected
,AssertionErrorCollector
,SoftAssertionsProvider
- All Known Subinterfaces:
StandardSoftAssertionsProvider
- All Known Implementing Classes:
AutoCloseableSoftAssertions
,Java6JUnitSoftAssertions
,Java6SoftAssertions
,JUnitJupiterSoftAssertions
,JUnitSoftAssertions
,SoftAssertions
public interface Java6StandardSoftAssertionsProvider extends SoftAssertionsProvider
AbstractStandardSoftAssertions compatible with Android. Duplicated fromStandardSoftAssertionsProvider
.- Since:
- 2.5.0 / 3.5.0
- See Also:
StandardSoftAssertionsProvider
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.assertj.core.api.SoftAssertionsProvider
SoftAssertionsProvider.ThrowingRunnable
-
-
Method Summary
All Methods Instance Methods Default Methods Modifier and Type Method Description default BooleanAssert
assertThat(boolean actual)
Creates a new instance of
.BooleanAssert
default BooleanArrayAssert
assertThat(boolean[] actual)
Creates a new instance of
.BooleanArrayAssert
default Boolean2DArrayAssert
assertThat(boolean[][] actual)
Creates a new instance of
.Boolean2DArrayAssert
default ByteAssert
assertThat(byte actual)
Creates a new instance of
.ByteAssert
default ByteArrayAssert
assertThat(byte[] actual)
Creates a new instance of
.ByteArrayAssert
default Byte2DArrayAssert
assertThat(byte[][] actual)
Creates a new instance of
.Byte2DArrayAssert
default CharacterAssert
assertThat(char actual)
Creates a new instance of
.CharacterAssert
default CharArrayAssert
assertThat(char[] actual)
Creates a new instance of
.CharArrayAssert
default Char2DArrayAssert
assertThat(char[][] actual)
Creates a new instance of
.Char2DArrayAssert
default DoubleAssert
assertThat(double actual)
Creates a new instance of
.DoubleAssert
default DoubleArrayAssert
assertThat(double[] actual)
Creates a new instance of
.DoubleArrayAssert
default Double2DArrayAssert
assertThat(double[][] actual)
Creates a new instance of
.Double2DArrayAssert
default FloatAssert
assertThat(float actual)
Creates a new instance of
.FloatAssert
default FloatArrayAssert
assertThat(float[] actual)
Creates a new instance of
.FloatArrayAssert
default Float2DArrayAssert
assertThat(float[][] actual)
Creates a new instance of
.Float2DArrayAssert
default IntegerAssert
assertThat(int actual)
Creates a new instance of
.IntegerAssert
default IntArrayAssert
assertThat(int[] actual)
Creates a new instance of
.IntArrayAssert
default Int2DArrayAssert
assertThat(int[][] actual)
Creates a new instance of
.Int2DArrayAssert
default LongAssert
assertThat(long actual)
Creates a new instance of
.LongAssert
default LongArrayAssert
assertThat(long[] actual)
Creates a new instance of
.LongArrayAssert
default Long2DArrayAssert
assertThat(long[][] actual)
Creates a new instance of
.Long2DArrayAssert
default ShortAssert
assertThat(short actual)
Creates a new instance of
.ShortAssert
default ShortArrayAssert
assertThat(short[] actual)
Creates a new instance of
.ShortArrayAssert
default Short2DArrayAssert
assertThat(short[][] actual)
Creates a new instance of
.Short2DArrayAssert
default FileAssert
assertThat(File actual)
Creates a new instance of
.FileAssert
default InputStreamAssert
assertThat(InputStream actual)
Creates a new instance of
.InputStreamAssert
default BooleanAssert
assertThat(Boolean actual)
Creates a new instance of
.BooleanAssert
default ByteAssert
assertThat(Byte actual)
Creates a new instance of
.ByteAssert
default CharacterAssert
assertThat(Character actual)
Creates a new instance of
.CharacterAssert
default CharSequenceAssert
assertThat(CharSequence actual)
Creates a new instance of
.CharSequenceAssert
default ProxyableClassAssert
assertThat(Class<?> actual)
Creates a new instance ofClassAssert
default DoubleAssert
assertThat(Double actual)
Creates a new instance of
.DoubleAssert
default FloatAssert
assertThat(Float actual)
Creates a new instance of
.FloatAssert
default IntegerAssert
assertThat(Integer actual)
Creates a new instance of
.IntegerAssert
default <T> ProxyableIterableAssert<T>
assertThat(Iterable<? extends T> actual)
Creates a new instance of
.IterableAssert
default LongAssert
assertThat(Long actual)
Creates a new instance of
.LongAssert
default ShortAssert
assertThat(Short actual)
Creates a new instance of
.ShortAssert
default StringAssert
assertThat(String actual)
Creates a new instance of
.StringAssert
default CharSequenceAssert
assertThat(StringBuffer actual)
Creates a new instance of
from aCharSequenceAssert
StringBuffer
.default CharSequenceAssert
assertThat(StringBuilder actual)
Creates a new instance of
from aCharSequenceAssert
StringBuilder
.default ThrowableAssert
assertThat(Throwable actual)
Creates a new instance of
.ThrowableAssert
default BigDecimalAssert
assertThat(BigDecimal actual)
Creates a new instance of
.BigDecimalAssert
default BigIntegerAssert
assertThat(BigInteger actual)
Creates a new instance of
.BigInteger
default UriAssert
assertThat(URI actual)
Creates a new instance of
.UriAssert
default AbstractUrlAssert<?>
assertThat(URL actual)
Creates a new instance of
.UrlAssert
default AtomicBooleanAssert
assertThat(AtomicBoolean actual)
Create assertion forAtomicBoolean
.default AtomicIntegerAssert
assertThat(AtomicInteger actual)
Create assertion forAtomicInteger
.default AtomicIntegerArrayAssert
assertThat(AtomicIntegerArray actual)
Create assertion forAtomicIntegerArray
.default <OBJECT> AtomicIntegerFieldUpdaterAssert<OBJECT>
assertThat(AtomicIntegerFieldUpdater<OBJECT> actual)
Create assertion forAtomicIntegerFieldUpdater
.default AtomicLongAssert
assertThat(AtomicLong actual)
Create assertion forAtomicLong
.default AtomicLongArrayAssert
assertThat(AtomicLongArray actual)
Create assertion forAtomicLongArray
.default <OBJECT> AtomicLongFieldUpdaterAssert<OBJECT>
assertThat(AtomicLongFieldUpdater<OBJECT> actual)
Create assertion forAtomicLongFieldUpdater
.default <VALUE> AtomicMarkableReferenceAssert<VALUE>
assertThat(AtomicMarkableReference<VALUE> actual)
Create assertion forAtomicMarkableReference
.default <VALUE> AtomicReferenceAssert<VALUE>
assertThat(AtomicReference<VALUE> actual)
Create assertion forAtomicReference
.default <ELEMENT> AtomicReferenceArrayAssert<ELEMENT>
assertThat(AtomicReferenceArray<ELEMENT> actual)
Create assertion forAtomicReferenceArray
.default <FIELD,OBJECT>
AtomicReferenceFieldUpdaterAssert<FIELD,OBJECT>assertThat(AtomicReferenceFieldUpdater<OBJECT,FIELD> actual)
Create assertion forAtomicReferenceFieldUpdater
.default <VALUE> AtomicStampedReferenceAssert<VALUE>
assertThat(AtomicStampedReference<VALUE> actual)
Create assertion forAtomicStampedReference
.default <RESULT> FutureAssert<RESULT>
assertThat(Future<RESULT> actual)
Creates a new instance of
.FutureAssert
default DateAssert
assertThat(Date actual)
Creates a new instance of
.DateAssert
default <T> IteratorAssert<T>
assertThat(Iterator<? extends T> actual)
Creates a new instance of
.IteratorAssert
default <T> ProxyableListAssert<T>
assertThat(List<? extends T> actual)
Creates a new instance of
.ListAssert
default <K,V>
ProxyableMapAssert<K,V>assertThat(Map<K,V> actual)
Creates a new instance of
.MapAssert
default <T extends Comparable<? super T>>
AbstractComparableAssert<?,T>assertThat(T actual)
Creates a new instance of
with standard comparison semantics.GenericComparableAssert
default <T> ProxyableObjectArrayAssert<T>
assertThat(T[] actual)
Creates a new instance of
.ObjectArrayAssert
default <T> Object2DArrayAssert<T>
assertThat(T[][] actual)
Creates a new instance of
.Object2DArrayAssert
default AbstractThrowableAssert<?,? extends Throwable>
assertThatCode(ThrowableAssert.ThrowingCallable shouldRaiseOrNotThrowable)
Allows to capture and then assert on aThrowable
more easily when used with Java 8 lambdas.default <T> ProxyableObjectAssert<T>
assertThatObject(T actual)
Creates a new instance of
for any object.ObjectAssert
default AbstractThrowableAssert<?,? extends Throwable>
assertThatThrownBy(ThrowableAssert.ThrowingCallable shouldRaiseThrowable)
Allows to capture and then assert on aThrowable
more easily when used with Java 8 lambdas.default AbstractThrowableAssert<?,? extends Throwable>
assertThatThrownBy(ThrowableAssert.ThrowingCallable shouldRaiseThrowable, String description, Object... args)
Allows to capture and then assert on aThrowable
likeassertThatThrownBy(ThrowingCallable)
but this method let you set the assertion description the same way you do withas(String, Object...)
.-
Methods inherited from interface org.assertj.core.api.AssertionErrorCollector
assertionErrorsCollected, collectAssertionError, onAssertionErrorCollected
-
Methods inherited from interface org.assertj.core.api.SoftAssertionsProvider
assertAll, assertAlso, check, proxy, wasSuccess
-
-
-
-
Method Detail
-
assertThat
default BigDecimalAssert assertThat(BigDecimal actual)
Creates a new instance of
.BigDecimalAssert
- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
-
assertThat
default BigIntegerAssert assertThat(BigInteger actual)
Creates a new instance of
.BigInteger
- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
- Since:
- 2.7.0 / 3.7.0
-
assertThat
default BooleanAssert assertThat(boolean actual)
Creates a new instance of
.BooleanAssert
- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
-
assertThat
default BooleanAssert assertThat(Boolean actual)
Creates a new instance of
.BooleanAssert
- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
-
assertThat
default BooleanArrayAssert assertThat(boolean[] actual)
Creates a new instance of
.BooleanArrayAssert
- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
-
assertThat
default Boolean2DArrayAssert assertThat(boolean[][] actual)
Creates a new instance of
.Boolean2DArrayAssert
- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
- Since:
- 3.17.0
-
assertThat
default ByteAssert assertThat(byte actual)
Creates a new instance of
.ByteAssert
- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
-
assertThat
default ByteAssert assertThat(Byte actual)
Creates a new instance of
.ByteAssert
- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
-
assertThat
default ByteArrayAssert assertThat(byte[] actual)
Creates a new instance of
.ByteArrayAssert
- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
-
assertThat
default Byte2DArrayAssert assertThat(byte[][] actual)
Creates a new instance of
.Byte2DArrayAssert
- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
- Since:
- 3.17.0
-
assertThat
default CharacterAssert assertThat(char actual)
Creates a new instance of
.CharacterAssert
- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
-
assertThat
default CharArrayAssert assertThat(char[] actual)
Creates a new instance of
.CharArrayAssert
- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
-
assertThat
default Char2DArrayAssert assertThat(char[][] actual)
Creates a new instance of
.Char2DArrayAssert
- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
- Since:
- 3.17.0
-
assertThat
default CharacterAssert assertThat(Character actual)
Creates a new instance of
.CharacterAssert
- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
-
assertThat
default ProxyableClassAssert assertThat(Class<?> actual)
Creates a new instance ofClassAssert
We don't return
ClassAssert
as it has overridden methods to annotated withSafeVarargs
.- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
-
assertThat
default <T extends Comparable<? super T>> AbstractComparableAssert<?,T> assertThat(T actual)
Creates a new instance of
with standard comparison semantics.GenericComparableAssert
- Type Parameters:
T
- the actual type.- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
-
assertThat
default <T> ProxyableIterableAssert<T> assertThat(Iterable<? extends T> actual)
Creates a new instance of
.IterableAssert
We don't return
IterableAssert
as it has overridden methods to annotated withSafeVarargs
.- Type Parameters:
T
- the actual element's type.- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
-
assertThat
default <T> IteratorAssert<T> assertThat(Iterator<? extends T> actual)
Creates a new instance of
.IteratorAssert
This is a breaking change in version 3.12.0: this method used to return an
ProxyableIterableAssert
.- Type Parameters:
T
- the actual element's type.- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
-
assertThat
default DoubleAssert assertThat(double actual)
Creates a new instance of
.DoubleAssert
- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
-
assertThat
default DoubleAssert assertThat(Double actual)
Creates a new instance of
.DoubleAssert
- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
-
assertThat
default DoubleArrayAssert assertThat(double[] actual)
Creates a new instance of
.DoubleArrayAssert
- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
-
assertThat
default Double2DArrayAssert assertThat(double[][] actual)
Creates a new instance of
.Double2DArrayAssert
- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
- Since:
- 3.17.0
-
assertThat
default FileAssert assertThat(File actual)
Creates a new instance of
.FileAssert
- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
-
assertThat
default <RESULT> FutureAssert<RESULT> assertThat(Future<RESULT> actual)
Creates a new instance of
.FutureAssert
- Type Parameters:
RESULT
- theFuture
element type.- Parameters:
actual
- the actual value- Returns:
- the created assertion object
-
assertThat
default InputStreamAssert assertThat(InputStream actual)
Creates a new instance of
.InputStreamAssert
- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
-
assertThat
default FloatAssert assertThat(float actual)
Creates a new instance of
.FloatAssert
- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
-
assertThat
default FloatAssert assertThat(Float actual)
Creates a new instance of
.FloatAssert
- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
-
assertThat
default FloatArrayAssert assertThat(float[] actual)
Creates a new instance of
.FloatArrayAssert
- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
-
assertThat
default Float2DArrayAssert assertThat(float[][] actual)
Creates a new instance of
.Float2DArrayAssert
- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
- Since:
- 3.17.0
-
assertThat
default IntegerAssert assertThat(int actual)
Creates a new instance of
.IntegerAssert
- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
-
assertThat
default IntArrayAssert assertThat(int[] actual)
Creates a new instance of
.IntArrayAssert
- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
-
assertThat
default Int2DArrayAssert assertThat(int[][] actual)
Creates a new instance of
.Int2DArrayAssert
- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
- Since:
- 3.17.0
-
assertThat
default IntegerAssert assertThat(Integer actual)
Creates a new instance of
.IntegerAssert
- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
-
assertThat
default <T> ProxyableListAssert<T> assertThat(List<? extends T> actual)
Creates a new instance of
.ListAssert
We don't return
IterableAssert
as it has overridden methods to annotated withSafeVarargs
.- Type Parameters:
T
- the actual element's type.- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
-
assertThat
default LongAssert assertThat(long actual)
Creates a new instance of
.LongAssert
- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
-
assertThat
default LongAssert assertThat(Long actual)
Creates a new instance of
.LongAssert
- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
-
assertThat
default LongArrayAssert assertThat(long[] actual)
Creates a new instance of
.LongArrayAssert
- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
-
assertThat
default Long2DArrayAssert assertThat(long[][] actual)
Creates a new instance of
.Long2DArrayAssert
- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
- Since:
- 3.17.0
-
assertThat
default <T> ProxyableObjectAssert<T> assertThat(T actual)
Creates a new instance of
.ObjectAssert
- Type Parameters:
T
- the type of the actual value.- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
-
assertThat
default <T> ProxyableObjectArrayAssert<T> assertThat(T[] actual)
Creates a new instance of
.ObjectArrayAssert
- Type Parameters:
T
- the type values of the actual array.- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
-
assertThat
default <T> Object2DArrayAssert<T> assertThat(T[][] actual)
Creates a new instance of
.Object2DArrayAssert
- Type Parameters:
T
- the type values of the actual array.- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
- Since:
- 3.17.0
-
assertThat
default <K,V> ProxyableMapAssert<K,V> assertThat(Map<K,V> actual)
Creates a new instance of
.MapAssert
We don't return
MapAssert
as it has overridden methods to annotated withSafeVarargs
.- Type Parameters:
K
- the type of keys in the map.V
- the type of values in the map.- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
-
assertThat
default ShortAssert assertThat(short actual)
Creates a new instance of
.ShortAssert
- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
-
assertThat
default ShortAssert assertThat(Short actual)
Creates a new instance of
.ShortAssert
- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
-
assertThat
default ShortArrayAssert assertThat(short[] actual)
Creates a new instance of
.ShortArrayAssert
- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
-
assertThat
default Short2DArrayAssert assertThat(short[][] actual)
Creates a new instance of
.Short2DArrayAssert
- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
- Since:
- 3.17.0
-
assertThat
default CharSequenceAssert assertThat(CharSequence actual)
Creates a new instance of
.CharSequenceAssert
- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
-
assertThat
default CharSequenceAssert assertThat(StringBuilder actual)
Creates a new instance of
from aCharSequenceAssert
StringBuilder
.- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
- Since:
- 3.11.0
-
assertThat
default CharSequenceAssert assertThat(StringBuffer actual)
Creates a new instance of
from aCharSequenceAssert
StringBuffer
.- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
- Since:
- 3.11.0
-
assertThat
default StringAssert assertThat(String actual)
Creates a new instance of
.StringAssert
- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
-
assertThat
default DateAssert assertThat(Date actual)
Creates a new instance of
.DateAssert
- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
-
assertThat
default AtomicBooleanAssert assertThat(AtomicBoolean actual)
Create assertion forAtomicBoolean
.- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
-
assertThat
default AtomicIntegerAssert assertThat(AtomicInteger actual)
Create assertion forAtomicInteger
.- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
-
assertThat
default AtomicIntegerArrayAssert assertThat(AtomicIntegerArray actual)
Create assertion forAtomicIntegerArray
.- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
-
assertThat
default <OBJECT> AtomicIntegerFieldUpdaterAssert<OBJECT> assertThat(AtomicIntegerFieldUpdater<OBJECT> actual)
Create assertion forAtomicIntegerFieldUpdater
.- Type Parameters:
OBJECT
- the type of the object holding the updatable field.- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
-
assertThat
default AtomicLongAssert assertThat(AtomicLong actual)
Create assertion forAtomicLong
.- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
-
assertThat
default AtomicLongArrayAssert assertThat(AtomicLongArray actual)
Create assertion forAtomicLongArray
.- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
-
assertThat
default <OBJECT> AtomicLongFieldUpdaterAssert<OBJECT> assertThat(AtomicLongFieldUpdater<OBJECT> actual)
Create assertion forAtomicLongFieldUpdater
.- Type Parameters:
OBJECT
- the type of the object holding the updatable field.- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
-
assertThat
default <VALUE> AtomicReferenceAssert<VALUE> assertThat(AtomicReference<VALUE> actual)
Create assertion forAtomicReference
.- Type Parameters:
VALUE
- the type of object referred to by theAtomicReference
.- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
-
assertThat
default <ELEMENT> AtomicReferenceArrayAssert<ELEMENT> assertThat(AtomicReferenceArray<ELEMENT> actual)
Create assertion forAtomicReferenceArray
.- Type Parameters:
ELEMENT
- the type of object referred to by theAtomicReferenceArray
.- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
-
assertThat
default <FIELD,OBJECT> AtomicReferenceFieldUpdaterAssert<FIELD,OBJECT> assertThat(AtomicReferenceFieldUpdater<OBJECT,FIELD> actual)
Create assertion forAtomicReferenceFieldUpdater
.- Type Parameters:
FIELD
- the type of the field which gets updated by theAtomicReferenceFieldUpdater
.OBJECT
- the type of the object holding the updatable field.- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
-
assertThat
default <VALUE> AtomicMarkableReferenceAssert<VALUE> assertThat(AtomicMarkableReference<VALUE> actual)
Create assertion forAtomicMarkableReference
.- Type Parameters:
VALUE
- The type of object referred to by this reference- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
-
assertThat
default <VALUE> AtomicStampedReferenceAssert<VALUE> assertThat(AtomicStampedReference<VALUE> actual)
Create assertion forAtomicStampedReference
.- Type Parameters:
VALUE
- The type of object referred to by this reference- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
-
assertThat
default ThrowableAssert assertThat(Throwable actual)
Creates a new instance of
.ThrowableAssert
- Parameters:
actual
- the actual value.- Returns:
- the created assertion Throwable.
-
assertThatThrownBy
default AbstractThrowableAssert<?,? extends Throwable> assertThatThrownBy(ThrowableAssert.ThrowingCallable shouldRaiseThrowable)
Allows to capture and then assert on aThrowable
more easily when used with Java 8 lambdas. Java 8 example :
Java 7 example :@Test default void testException() { SoftAssertions softly = new SoftAssertions(); softly.assertThatThrownBy(() -> { throw new Exception("boom!"); }).isInstanceOf(Exception.class) .hasMessageContaining("boom"); }
SoftAssertions softly = new SoftAssertions(); softly.assertThatThrownBy(new ThrowingCallable() { @Override default Void call() throws Exception { throw new Exception("boom!"); } }).isInstanceOf(Exception.class) .hasMessageContaining("boom");
- Parameters:
shouldRaiseThrowable
- TheThrowableAssert.ThrowingCallable
or lambda with the code that should raise the throwable.- Returns:
- The captured exception or
null
if none was raised by the callable.
-
assertThatThrownBy
default AbstractThrowableAssert<?,? extends Throwable> assertThatThrownBy(ThrowableAssert.ThrowingCallable shouldRaiseThrowable, String description, Object... args)
Allows to capture and then assert on aThrowable
likeassertThatThrownBy(ThrowingCallable)
but this method let you set the assertion description the same way you do withas(String, Object...)
.Example:
If the provided@Test default void testException() { SoftAssertions softly = new SoftAssertions(); // if this assertion failed (but it doesn't), the error message would start with [Test explosive code] softly.assertThatThrownBy(() -> { throw new IOException("boom!") }, "Test explosive code") .isInstanceOf(IOException.class) .hasMessageContaining("boom"); }
ThrowingCallable
does not raise an exception, an error is immediately thrown.The test description provided is honored but not the one with
as(String, Object...)
, example:// assertion will fail but "display me" won't appear in the error message softly.assertThatThrownBy(() -> {}).as("display me") .isInstanceOf(Exception.class); // assertion will fail AND "display me" will appear in the error message softly.assertThatThrownBy(() -> {}, "display me") .isInstanceOf(Exception.class);
- Parameters:
shouldRaiseThrowable
- TheThrowableAssert.ThrowingCallable
or lambda with the code that should raise the throwable.description
- the new description to set.args
- optional parameter if description is a format String.- Returns:
- the created
ThrowableAssert
. - Since:
- 3.9.0
-
assertThatCode
default AbstractThrowableAssert<?,? extends Throwable> assertThatCode(ThrowableAssert.ThrowingCallable shouldRaiseOrNotThrowable)
Allows to capture and then assert on aThrowable
more easily when used with Java 8 lambdas.Example :
If the providedThrowingCallable callable = () -> { throw new Exception("boom!"); }; // assertion succeeds assertThatCode(callable).isInstanceOf(Exception.class) .hasMessageContaining("boom"); // assertion fails assertThatCode(callable).doesNotThrowAnyException();
ThrowableAssert.ThrowingCallable
does not validate against next assertions, an error is immediately raised, in that case the test description provided withas(String, Object...)
is not honored.
To use a test description, useassertThatCode(ThrowableAssert.ThrowingCallable)
as shown below.ThrowingCallable doNothing = () -> { // do nothing }; // assertion fails and "display me" appears in the assertion error assertThatCode(doNothing).as("display me") .isInstanceOf(Exception.class); // assertion will fail AND "display me" will appear in the error Throwable thrown = catchThrowable(doNothing); assertThatCode(thrown).as("display me") .isInstanceOf(Exception.class);
This method was not named
assertThat
because the java compiler reported it ambiguous when used directly with a lambda :(- Parameters:
shouldRaiseOrNotThrowable
- TheThrowableAssert.ThrowingCallable
or lambda with the code that should raise the throwable.- Returns:
- The captured exception or
null
if none was raised by the callable. - Since:
- 3.7.0
-
assertThatObject
default <T> ProxyableObjectAssert<T> assertThatObject(T actual)
Creates a new instance of
for any object.ObjectAssert
This overload is useful, when an overloaded method of assertThat(...) takes precedence over the generic
assertThat(Object)
.Example:
Cast necessary becauseassertThat(List)
"forgets" actual type:
No cast needed, but also no additional list assertions:assertThat(new LinkedList<>(asList("abc"))).matches(list -> ((Deque<String>) list).getFirst().equals("abc"));
assertThatObject(new LinkedList<>(asList("abc"))).matches(list -> list.getFirst().equals("abc"));
- Type Parameters:
T
- the type of the actual value.- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
- Since:
- 3.12.0
-
assertThat
default UriAssert assertThat(URI actual)
Creates a new instance of
.UriAssert
- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
-
assertThat
default AbstractUrlAssert<?> assertThat(URL actual)
Creates a new instance of
.UrlAssert
- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
-
-