S
- the type of the Subject
T
- the target type tested by the Subject
public abstract class SubjectTest<S extends com.google.common.truth.Subject,T>
extends java.lang.Object
Subject
test suites.Modifier and Type | Field and Description |
---|---|
protected static java.lang.String |
BUT_WAS |
protected static java.lang.String |
EXPECTED |
protected static java.lang.String |
EXPECTED_NOT_TO_BE |
protected static java.lang.String |
NULL |
Constructor and Description |
---|
SubjectTest() |
Modifier and Type | Method and Description |
---|---|
protected S |
assertWithSubjectThat(T actual)
Creates a subject under the test with the passed actual value.
|
protected java.lang.AssertionError |
expectFailure(com.google.common.truth.ExpectFailure.SimpleSubjectBuilderCallback<S,T> assertionCallback)
Creates an
AssertionError caused by the passed callback. |
protected void |
expectSomeFailure(com.google.common.truth.ExpectFailure.SimpleSubjectBuilderCallback<S,T> assertionCallback)
Expects that the passed callback causes
AssertionError and ignores it. |
protected abstract com.google.common.truth.Subject.Factory<S,T> |
subjectFactory() |
protected static final java.lang.String EXPECTED
protected static final java.lang.String BUT_WAS
protected static final java.lang.String EXPECTED_NOT_TO_BE
protected static final java.lang.String NULL
protected S assertWithSubjectThat(T actual)
protected java.lang.AssertionError expectFailure(com.google.common.truth.ExpectFailure.SimpleSubjectBuilderCallback<S,T> assertionCallback)
AssertionError
caused by the passed callback.
Example of usage:
AssertionError failure = expectFailure(whenTesting -> whenTesting.that(myType).hasProperty());
protected void expectSomeFailure(com.google.common.truth.ExpectFailure.SimpleSubjectBuilderCallback<S,T> assertionCallback)
AssertionError
and ignores it.
This method is for test cases where the produced error is of no interest. Example of usage:
expectSomeFailure(whenTesting -> whenTesting.that(myType).hasProperty());