こちらで書いたコードに対してパラメタライズドテストを書いていきます。
環境
testImplementation 'junit:junit:4.12'
コード
Java で書くときは、Static な感じで書いてたのは companion object にしました。
@RunWith(Parameterized::class) internal class HtmlUtilSpec(private val HtmlText: String, private val planeText: String) { @Test fun ConvertHtmlToPlaneText() { Assert.assertEquals(HtmlText.removehtmlTag(), planeText) } companion object { @Parameterized.Parameters @JvmStatic fun data() = listOf( arrayOf("hello neet", "hello neet"), arrayOf("<h1>hello</h1>", "hello"), arrayOf("<br>hello\n", "hello"), arrayOf("<h1>hello<h1>", "hello") ) } }