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

🐞: [Junit5] Parameterized test failed in @BeforeEach lacks parameters data in result.json #1061

Open
1 task done
ar4development opened this issue Jun 28, 2024 · 0 comments
Labels
triage type:bug Something isn't working

Comments

@ar4development
Copy link

ar4development commented Jun 28, 2024

What happened?

Say we have the code like this:

import io.qameta.allure.Step
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.DisplayName
import org.junit.jupiter.api.Tag
import org.junit.jupiter.params.ParameterizedTest
import org.junit.jupiter.params.provider.CsvSource

class ExperimentTest {

    @BeforeEach
    fun setUp() {
        throw Exception("Like fail in setup")
    }

    @ParameterizedTest(name = "{0} - {1}")
    @DisplayName("Test stats with parameters")
    @CsvSource(value = [
        "val1-1, val2-1",
    ])
    @Tag("testops_test")
    fun test1(val1: String, val2: String) {
        doTestStepFor("$val1 - $val2")
    }

    @Step("Doing test step for {stepSuffix}")
    private fun doTestStepFor(stepSuffix: String) {
        println(">>>>>>> Test step done: $stepSuffix")
    }

}

Run the test and observe result.json.

OBSERVED: There is no parameter data in parameters like:

  "parameters": [
    {
      "name": "UniqueId",
      "value": "[engine:junit-jupiter]/[class:testops_test.ExperimentTest]/[test-template:test1(java.lang.String, java.lang.String)]/[test-template-invocation:#1]",
      "mode": "hidden"
    }
  ],

This is kind of a problem since when the test passes after retry (say we have commented the exception line and run test once again), the parameters are there for successful result.json

  "parameters": [
    {
      "name": "UniqueId",
      "value": "[engine:junit-jupiter]/[class:testops_test.ExperimentTest]/[test-template:test1(java.lang.String, java.lang.String)]/[test-template-invocation:#1]",
      "mode": "hidden"
    },
    {
      "name": "val1",
      "value": "val1-1"
    },
    {
      "name": "val2",
      "value": "val2-1"
    }
  ],

and TestOps fails to merge those two test runs into a single retry chain.

What Allure Integration are you using?

allure-junit5

What version of Allure Integration you are using?

2.25.0

What version of Allure Report you are using?

2.25.0

Code of Conduct

  • I agree to follow this project's Code of Conduct
@ar4development ar4development added triage type:bug Something isn't working labels Jun 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage type:bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant