Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[JVM] Table to JUnit Jupiter dynamic tests #520

Open
Xfel opened this issue Mar 16, 2024 · 0 comments
Open

[JVM] Table to JUnit Jupiter dynamic tests #520

Xfel opened this issue Mar 16, 2024 · 0 comments

Comments

@Xfel
Copy link

Xfel commented Mar 16, 2024

The big advantage of the Table assertions is that they are a lot simpler to use than comparative options like JUnit's ParameterizedTest.

However one downside in comparison is that the Table Test shows up as a single node in the test report, whereas ParameterizedTest will add an entry for each parameter set. If you have a big table, that makes it rather complicated to see what is failing and what is not. Also, we cannot rerun individual failing rows.

A solution would be to take advantage of JUnit's dynamic tests. Instead of just calling the table forAll function, we could use a setup like this:

@TestFactory
fun myTableTest() = tableOf("a", "b", "result")
    .row(0, 0, 1)
    .row(1, 2, 4)
    .asDynamicTest { a, b, result ->
        assertThat(a + b).isEqualTo(result)
    }

The asDynamicTest function would be an extension function residing in a JVM + JUnit 5 exclusive file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant