There is a lot of source code that is surrounded by try-catch block and the uncaught exceptions are passed to Util.handleException. This could hide potential issues when running the unit tests because there are a lot of cases where a callback is set in the SDK and an assert statement is executed in the callback, but that assertion exception is handled in Util.handleException and never thrown again and the test is false positive.
To fix that I've introduced two methods:
AbstractTest.stopLeanplumExceptionHandling() - mocks the Util.handleException to rethrow the passed exception
AbstractTest.resumeLeanplumExceptionHandling() - returns the default behaviour of Util.handleException if you need that logic during a test
Background
There is a lot of source code that is surrounded by try-catch block and the uncaught exceptions are passed to
Util.handleException
. This could hide potential issues when running the unit tests because there are a lot of cases where a callback is set in the SDK and an assert statement is executed in the callback, but that assertion exception is handled inUtil.handleException
and never thrown again and the test is false positive.To fix that I've introduced two methods:
AbstractTest.stopLeanplumExceptionHandling()
- mocks the Util.handleException to rethrow the passed exceptionAbstractTest.resumeLeanplumExceptionHandling()
- returns the default behaviour ofUtil.handleException
if you need that logic during a testAlso fixed several tests that started failing.