reactormonk
06/24/2023, 10:45 AMMethod parse in android.net.Uri not mocked.
, even though I added @RunWith(RobolectricTestRunner::class)
on top of my class.reactormonk
06/24/2023, 10:45 AMimport android.net.Uri
import io.kotest.matchers.shouldBe
import org.junit.jupiter.api.Test
import org.junit.runner.RunWith
import org.robolectric.RobolectricTestRunner
import org.robolectric.annotation.Config
@RunWith(RobolectricTestRunner::class)
@Config(sdk = [33])
class YoutubePlayerKtTest {
val youtubeShortURL = Uri.parse("<https://youtu.be/l6rS8Dv5g-8>")
val youtubeLongURL = Uri.parse("<https://www.youtube.com/watch?v=l6rS8Dv5g-8>")
val youtubePlaylistURL = Uri.parse("<https://www.youtube.com/watch?v=BE2Fj0W4jP4&list=PLmWYEDTNOGUIDlp5epnDhPH-zPI0KfTQG>")
@Test
fun testShort() {
parseYoutubeURL(youtubeShortURL) shouldBe CardMessage.YoutubeVideo("l6rS8Dv5g-8")
}
@Test
fun testLong() {
parseYoutubeURL(youtubeLongURL) shouldBe CardMessage.YoutubeVideo("l6rS8Dv5g-8")
}
@Test
fun testPlaylist() {
parseYoutubeURL(youtubePlaylistURL) shouldBe CardMessage.YoutubePlaylist("PLmWYEDTNOGUIDlp5epnDhPH-zPI0KfTQG")
}
}
Arun M
06/30/2023, 3:12 AM