reactormonk
Method parse in android.net.Uri not mocked.
@RunWith(RobolectricTestRunner::class)
import 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
A modern programming language that makes developers happier.