You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description
When the exception is thrown in the JUnit test which uses KoinTestRule, it fails other tests as well because the exception is not caught in the rule.
To Reproduce
I created a simple demo to illustrate the issue.
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
class KoinTest {
@get:Rule
val koinRule = KoinTestRule.create {}
@Test
fun first() {
throw Exception()
}
@Test
fun second() {}
}
Second test should pass but fails with java.lang.IllegalStateException: A KoinContext is already started.
base.evaluate() throws an exception from the test which is not caught and Koin is not properly stopped. Solution is to catch the exception or extend TestWatcher instead of TestRule because TestWatcher already handles exceptions internally.
Koin project used and used version koin-test version 2.1.5
The text was updated successfully, but these errors were encountered:
mottljan
pushed a commit
to mottljan/koin
that referenced
this issue
May 16, 2020
Description
When the exception is thrown in the JUnit test which uses
KoinTestRule
, it fails other tests as well because the exception is not caught in the rule.To Reproduce
I created a simple demo to illustrate the issue.
Second test should pass but fails with
java.lang.IllegalStateException: A KoinContext is already started
.Here is the implementation in the
KoinTestRule
.base.evaluate()
throws an exception from the test which is not caught and Koin is not properly stopped. Solution is to catch the exception or extendTestWatcher
instead ofTestRule
becauseTestWatcher
already handles exceptions internally.Koin project used and used version
koin-test version 2.1.5
The text was updated successfully, but these errors were encountered: