Skip to content

Commit

Permalink
✅ Isolate test by using mocked dependency rule to tear down state
Browse files Browse the repository at this point in the history
By setting the dependency provider to null, all async tasks are still
live. And newly created dependencies are no more managed by the mocked
dependency rule. So new async tasks are not waited properly at the end
of the test.

This means that the test was previously still living while other tests
were executed.

By using the rule to tear down the in memory state, then all async tasks
are waited on properly and all new dependencies are still managed and
injected by the rule.
  • Loading branch information
TurpIF committed Oct 7, 2021
1 parent ef42c0f commit cb41943
Showing 1 changed file with 1 addition and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ package com.criteo.publisher.integration

import android.content.SharedPreferences
import com.criteo.publisher.CriteoUtil.givenInitializedCriteo
import com.criteo.publisher.DependencyProvider
import com.criteo.publisher.MockableDependencyProvider
import com.criteo.publisher.mock.MockedDependenciesRule
import com.criteo.publisher.mock.SpyBean
import com.criteo.publisher.util.BuildConfigWrapper
Expand Down Expand Up @@ -91,9 +89,8 @@ class IntegrationRegistryTest {
fun integration_GivenPreviouslyDeclaredOneAndNewSession_ReturnDeclaredOne() {
integrationRegistry.declare(Integration.IN_HOUSE)

MockableDependencyProvider.setInstance(null)
mockedDependenciesRule.resetAllDependencies()
givenInitializedCriteo()
integrationRegistry = DependencyProvider.getInstance().provideIntegrationRegistry()

val integration = integrationRegistry.readIntegration()

Expand Down

0 comments on commit cb41943

Please sign in to comment.