-
Notifications
You must be signed in to change notification settings - Fork 7
Description
Thank you for this great library! I would like to ask about adding support for a new feature.
I want to create a test case where I pass an input String
along with an expected output data type that the subject in test will parse the string into another data type, in this situation, a FloatArray
.
I noticed that the TestParameterInjector supports this feature through a set of parameters. Is there a way to achieve the same functionality with Burst?
I have tried several approaches to accomplish this, and while they work, they feel a bit off. Here's what I have attempted:
- Using a
Pair<String, FloatArray>
- Using a
data class
to wrap the values - Using a simple
class
All three methods work, but the generated test names are quite unhelpful. For instance, the following test case:
@Burst
class SvgViewBoxTest {
@Test
fun testViewBoxWithSpacesAsSeparators(
params: Pair<String, FloatArray> = burstValues(
"0 0 120 120" to floatArrayOf(0f, 0f, 120f, 120f),
"10 0 3000 120" to floatArrayOf(10f, 0f, 3000f, 120f),
"0 0 0 1200" to floatArrayOf(0f, 0f, 0f, 1200f),
"10 150 500 20" to floatArrayOf(10f, 150f, 500f, 20f),
),
) {
val (viewBox, expected) = params
println("viewBox = $viewBox, expected = ${expected.toList()}")
val svgNode = SvgRootNode(
parent = XmlRootNode(children = mutableSetOf()),
children = mutableSetOf(),
attributes = mutableMapOf(
"viewBox" to viewBox,
),
)
val actual = svgNode.parseViewBox()
assertContentEquals(expected, actual)
}
}
Outputs the following test names:
testViewBoxWithSpacesAsSeparators
testViewBoxWithSpacesAsSeparators_1_to
testViewBoxWithSpacesAsSeparators_2_to
testViewBoxWithSpacesAsSeparators_3_to
In contrast, another test case:
@Burst
class NumbersTest {
@BeforeTest
fun setup() {
println("before running test")
}
@Test
fun testSumIsEven(
fistNumber: Int = burstValues(2, 4, 6),
secondNumber: Int = burstValues(2, 4, 6),
) {
assertEquals(0, (fistNumber + secondNumber) % 2)
}
}
yields more descriptive output:
testSumIsEven
testSumIsEven_2_4
testSumIsEven_2_6
testSumIsEven_4_2
testSumIsEven_4_4
testSumIsEven_4_6
testSumIsEven_6_2
testSumIsEven_6_4
testSumIsEven_6_6
For the "set of parameter" option, it would be helpful if the output were formatted like this: testViewBoxWithSpacesAsSeparators_0_0_120_120_to_0f_0f_120f_120f
.
Alternatively, another format could be: testViewBoxWithSpacesAsSeparators_[0_0_120_120]_to_[0f 0f 120f 120f]
, however, I believe the last option may not be feasible because using [
and ]
as characters are not allowed in test names.
I would appreciate any guidance on how to make the test name outputs more informative when using Burst.
Thank you!