我想实现groovy
参数化测试,其中测试名称将使用参数值构建。我知道如何在java
中执行此操作(我也找到了java回答here,但没有找到groovy
)
所以我需要用相同的选项改进我的groovy
参数化单元测试:
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.Parameterized
@RunWith(Parameterized)
class TestSimple {
String numberA
String numberB
String expectedResult
TestSimple(numA, numB, expected) {
numberA = numA
numberB = numB
expectedResult = expected
}
@Parameterized.Parameters
static data1() {
[
[null, "asd|asd|||ASD||ASD", 'result for first case'],
['09909', "asd|asd|||ASD||ASD", 'result for second case']
]*.toArray()
}
@Test
void testLogonRequest1() throws Exception {
println numberA + ":" + numberB
}
}
用参数值
替换有序数字TestSimple
[0]
testLogonRequest1[0]
[1]
testLogonRequest1[1]
预期结果类似于:
TestSimple
[used parameters: <numberA0value>, <numberB0value>]
testLogonRequest1[expected result: <expectedResult0Value>]
[used parameters: <numberA1value>, <numberB1value>]
testLogonRequest1[expected result: <expectedResult1Value>]
有什么想法吗?