我想用三个参数来参数我JUnit5测试:string
,string
和list<string>
。如何将列表作为JUnit5的参数化测试参数传递?
至今没有运气使用@CsvSource
,这是通过params用于在我的用例的最方便的方式时:
的隐式转换到java.lang.String类型的对象转换为 类型的Java。 util.List
实际测试是:
@ParameterizedTest()
@CsvSource(
"2,1"
)
fun shouldGetDataBit(first: Int, second: String, third: List<String>) {
...
}
这是可能的任何想法?我在这里使用Kotlin,但它应该是不相关的。
仅供参考:我更新了JUnit 5.1的用户指南以包含此类示例。 https://github.com/junit-team/junit5/commit/eb6e401fde681d7da649025391691ff5a45ca0f0 –
产生的文档的变化是在最新的快照已经显现:http://junit.org/junit5/docs/snapshot/user-guide/#writing -tests参数化的测试来源,MethodSource –