Skip to content

Instantly share code, notes, and snippets.

@aanandshekharroy
Created February 10, 2018 11:04
Show Gist options
  • Save aanandshekharroy/5b2e0a0fb510aa0cf137c9d2cae4572a to your computer and use it in GitHub Desktop.
Save aanandshekharroy/5b2e0a0fb510aa0cf137c9d2cae4572a to your computer and use it in GitHub Desktop.
Used JUnitParams to create parametrized unit test in Kotlin
import junitparams.JUnitParamsRunner
import junitparams.Parameters
import org.junit.Test;
import org.junit.Assert.*;
import org.junit.Before
import org.junit.runner.RunWith
import org.junit.runners.Parameterized
import java.util.*
@RunWith(JUnitParamsRunner::class)
class TestingModuleTest {
lateinit var a :TestingModule
@Before
fun setUp(){
a = TestingModule()
}
fun getReverseStringData() = arrayOf(arrayOf("abc","cba"),arrayOf("aab","baa"))
@Test
@Parameters(method = "getReverseStringData")
fun testReverse(input:String,expected:String){
assertEquals(expected,a.reverse(input))
}
}
@aanandshekharroy
Copy link
Author

Made it public

@zkwzk
Copy link

zkwzk commented Jul 11, 2019

it's great, thanks for sharing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment