PeterWippermann / parameterized-suite

Provides a new Runner for JUnit 4 that combines the features of Suite and Parameterized

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Index is 0 for all tests

Borisfrad opened this issue · comments

When using the {index} parameter in the test name (or not using test names at all) the index is always 0.
The other parameters are correct.

Thanks for reporting this, @Borisfrad !

Do you speak about test names at Suite level (annotated with @RunWith(ParameterizedSuite.class)) or on Test class level ((annotated with @RunWith(Parameterized.class))?

Maybe you could also share your test class?

In addition, have you build a hierarchy of tests, i. e. ParameterizedSuites of ParameterizedSuites?

I'm sorry @Borisfrad, but I think what you thought would be a bug is by design. Please keep in mind:

The execution strategy is: "All test cases per parameter", i.e. for every parameter all test cases are executed in a row, then the test cases are executed for the next parameter and so on

From the wiki:

The root test suite has a sub-node for every Q&A object from the parameter set (e.g. "[Q&A: Who's left the building?]").
For each of these Q&As the QuestionReaderTest and AnswerReaderTest are executed - we call this forking.
Since these tests are Parameterized they also introduce another level in the test execution hierarchy for their parameters ("[Question: Who's left the building?]" and "[Answer for: Who's left the building?]"; these patterns are defined in @parameters(name="...")). But since the tests run in a fork, only a single parameter of the set is passed to them.

The executions of your parameterized test are independent from each other and thus the {index} in their name will always be 0.