Add RecordedRequests testing utility class #499
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
tests in KiwiXmlAssertTest started failing, because they were getting a JUnit 4
ComparisonFailure (which is a subclass of AssertionError). So, I changed the assertions
to only check that an instance of AssertionError was thrown. See below for the Gory Details.
Gory Details:
okhttp3.mockwebserver version 4.12.0 depends on JUnit 4 (and
MockWebServer actually extends ExternalResource). This caused some
tests in KiwiXmlAssertTest to fail because they were expecting errors to
be exactly instance of AssertionError. But xmlunit-assertj (deep inside
org.xmlunit.assertj.error.ComparisonFailureErrorFactory) actually changes
the error it throws to be an org,junit.ComparisonFailure if that class is
available at runtime, whereas it simply delegates to AssertJ and throws a
regular AssertionError if it is not available. So, by mockwebserver
depending on JUnit 4.x, it makes ComparisonFailure available on the
class path, so the throwable changes to ComparisonFailure instead of
a raw AssertionError. ComparisonFailure is a subclass of AssertionError
so we can fix it by changing our assertions in KiwiXmlAssertTest to
only check that a Throwable is an instance of (not exactly) AssertionError,
so it will pass whether ComparisonFailure exists or not.
I don't know for sure, but am guessing they have to do it this way
for JUnit 4.x environments to work properly. But I'm not at all sure.
Closes #492