Skip to content

Is it possible to set a different Test key for each dynamic test iteration? #59

Description

@paulmwhite

Given a dynamic test like the below I can't see how it's possible to use an annotation and have a unique key for each iteration:

class UnitTest {

    @Nested
    inner class Something {
        @TestFactory
        fun `something() successfully`(): List<DynamicTest> {
            fun test(
                something: String,
            ): DynamicTest {
                return DynamicTest.dynamicTest(
                    "something: $something",
                ) {
                    //    Test implementation
                }
            }

            return listOf(
                test(
                    "one"
                ),
                test(
                    "two"
                ),
            )
        }
    }
}

Is there any workaround or solution, perhaps a way to set the key in the test body?

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions