Here is the use case that I am trying to solve:
- I have a standard test module which has a setup_all method and a describe block.
- Now, I make an API call in the setup_all method and set an array of values in the context.
- I would like to iterate over these array of values and generate test cases for every value in the array.
Is there any way to achieve this?
Hence, ideally, I would like to receive the “context” in the describe macro and then “map” the array of values over the test macro. However, the describe block does not have access to the context which I have set in the setup_all function.
Or else, I do have a context (array of values) inside the test. Then, I should be able to dynamically iterate over this array of values and define test cases dynamically inside this test. Thus, it would be nested test cases.
The problem I am trying to solve is to avoid defining so many test cases. This is because the array of values will be close to 30 and it will just have the same “exact” code.