I have a class with multiple @Test methods each with a different functionality.
class myTests
{
@Test
test1()
{
...............
}
@Test
test2()
{
...............
}
}
Am following the Data driven approach where I have the data in Excel. Each row in excel sheet corresponds to a different test case that should execute the test methods in above class.
Below is the sample data from excel sheet which contains the method name as one of the parameters(eg: test1, test2) and also a flag which determines if the case should be picked up for execution or not at runtime (eg: y,n)
case1 data1 data2 data3........test1 y
case2 data4 data5 data6........test1 y
case3 data7 data8 data9........test2 y
case4 data10 data11 data12........test1 n
Below are the questions I have:
- How to map the cases to corresponding test methods
- How to make the specific cases run based on the flag
My understanding is that using DataProvider annotation, a test method can run with different input data. But am not sure how to map the test methods with corresponding test data if there are multiple test methods in single class.
Also I tried looking for IAnnotationTransformer that can be used to alter the runtime behaviour of test method, but could not find a way to send the flag data from excel to the transformer class.
Thanks in advance..