使用 Robolectric 测试网页是否通过 intent 成功打开

Test if a webpage was opened succesfully via intent using Robolectric

我有如下简单的功能

fun openWebPage(url: String) {
    val openURL = Intent(Intent.ACTION_VIEW)
    openURL.data = Uri.parse(url)
    startActivity(openURL)
}

如何使用Robolectric测试验证网页是否打开成功?

此代码片段有助于捕获该场景

    val shadow = Shadows.shadowOf(activity)
    val exp_url = "www.google.com"
    val intent =  shadow.nextStartedActivity
    val url = intent.data.toString()
    assertEquals(exp_url,url)