Skip to content

Commit

Permalink
Add some missing clearAllMocks() calls
Browse files Browse the repository at this point in the history
  • Loading branch information
MGaetan89 committed Dec 18, 2024
1 parent 8522d6d commit 13cf17b
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import android.content.Context
import androidx.test.core.app.ApplicationProvider
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.comscore.Analytics
import io.mockk.clearAllMocks
import io.mockk.mockkStatic
import io.mockk.unmockkAll
import org.junit.runner.RunWith
import org.robolectric.Shadows.shadowOf
import kotlin.test.AfterTest
Expand All @@ -37,7 +37,7 @@ class SRGAnalyticsSingletonTest {

@AfterTest
fun tearDown() {
unmockkAll()
clearAllMocks()
}

@Test(expected = IllegalArgumentException::class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ import ch.srgssr.pillarbox.analytics.commandersact.CommandersActPageView
import ch.srgssr.pillarbox.analytics.comscore.ComScore
import ch.srgssr.pillarbox.analytics.comscore.ComScorePageView
import io.mockk.Called
import io.mockk.clearAllMocks
import io.mockk.confirmVerified
import io.mockk.mockk
import io.mockk.verify
import kotlin.test.AfterTest
import kotlin.test.BeforeTest
import kotlin.test.Test

Expand All @@ -31,6 +33,11 @@ class SRGAnalyticsTest {
)
}

@AfterTest
fun tearDown() {
clearAllMocks()
}

@Test
fun `sendPageView invokes comScore and commandersAct`() {
val commandersActPageView = CommandersActPageView(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import androidx.test.ext.junit.runners.AndroidJUnit4
import ch.srgssr.pillarbox.analytics.AnalyticsConfig
import com.comscore.Analytics
import com.comscore.PublisherConfiguration
import io.mockk.clearAllMocks
import io.mockk.confirmVerified
import io.mockk.every
import io.mockk.mockk
import io.mockk.mockkStatic
import io.mockk.unmockkAll
import io.mockk.verify
import org.junit.runner.RunWith
import org.robolectric.Shadows.shadowOf
Expand Down Expand Up @@ -44,7 +44,7 @@ class ComScoreSrgTest {

@AfterTest
fun tearDown() {
unmockkAll()
clearAllMocks()
}

@Test(expected = IllegalArgumentException::class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,31 @@ package ch.srgssr.pillarbox.core.business.tracker

import androidx.media3.exoplayer.ExoPlayer
import androidx.test.ext.junit.runners.AndroidJUnit4
import io.mockk.clearAllMocks
import io.mockk.mockk
import io.mockk.verifySequence
import org.junit.runner.RunWith
import kotlin.test.AfterTest
import kotlin.test.BeforeTest
import kotlin.test.Test

@RunWith(AndroidJUnit4::class)
class SRGEventLoggerTrackerTest {
private lateinit var player: ExoPlayer

@BeforeTest
fun setUp() {
player = mockk(relaxed = true)
}

@AfterTest
fun tearDown() {
clearAllMocks()
}

@Test
fun `event logger`() {
val player = mockk<ExoPlayer>(relaxed = true)
val eventLogger = SRGEventLoggerTracker.Factory().create()

eventLogger.start(player, Unit)
eventLogger.stop(player)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ import androidx.test.ext.junit.runners.AndroidJUnit4
import ch.srgssr.pillarbox.analytics.BuildConfig
import com.comscore.Analytics
import com.comscore.streaming.StreamingAnalytics
import io.mockk.clearAllMocks
import io.mockk.confirmVerified
import io.mockk.every
import io.mockk.mockk
import io.mockk.mockkStatic
import io.mockk.unmockkAll
import io.mockk.verify
import org.junit.runner.RunWith
import kotlin.test.AfterTest
Expand All @@ -33,7 +33,7 @@ class ComScoreTrackerTest {

@AfterTest
fun tearDown() {
unmockkAll()
clearAllMocks()
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package ch.srgssr.pillarbox.player.network

import ch.srgssr.pillarbox.player.network.RequestSender.send
import ch.srgssr.pillarbox.player.network.RequestSender.toJsonRequestBody
import io.mockk.clearAllMocks
import io.mockk.every
import io.mockk.mockk
import kotlinx.serialization.Serializable
Expand Down Expand Up @@ -36,6 +37,8 @@ class RequestSenderTest {
@AfterTest
fun tearDown() {
buffer.close()

clearAllMocks()
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ import androidx.media3.common.Player
import androidx.media3.ui.PlayerNotificationManager.MediaDescriptionAdapter
import androidx.test.core.app.ApplicationProvider
import androidx.test.ext.junit.runners.AndroidJUnit4
import io.mockk.clearAllMocks
import io.mockk.every
import io.mockk.mockk
import org.junit.runner.RunWith
import org.robolectric.Shadows.shadowOf
import kotlin.test.AfterTest
import kotlin.test.BeforeTest
import kotlin.test.Test
import kotlin.test.assertContentEquals
Expand All @@ -35,6 +37,11 @@ class PillarboxMediaDescriptionAdapterTest {
mediaDescriptionAdapter = PillarboxMediaDescriptionAdapter(pendingIntent, context)
}

@AfterTest
fun tearDown() {
clearAllMocks()
}

@Test
fun `get current content title, with displayTitle and title in metadata`() {
val displayTitle = "Media display title"
Expand Down

0 comments on commit 13cf17b

Please sign in to comment.