So I have created a parameterized test, which is a simple restassured test which logs into a user account. I have some spring bean config in place, which you can specify a profile to pick up a certain test env, QA1, QA2, QA3 for example. In each env I have different test accounts, I want to be able to run tests for QA1 for example it will run my ParameterizedTest for all the QA1 user accounts. I'm hitting a block atm in that when I try to specify CSV source for my ParameterizedTest it requires a static variable for the filename, and my env config coming from the spring bean is not static. Any ideas on how I might achieve this? Some code...
@SpringBootTest
public class LoginLogoutTest {
@Autowired
ParamsConfig paramsConfig;
String filename = paramsConfig.getUsersDataFile();
@ParameterizedTest
@CsvFileSource(resources = filename, numLinesToSkip = 1)
public void loginLogoutTest(String username, String password) {
//Some test stuff
}
}
I tried to specify via the bean config for CsvFileSource, but that requires static filepath.
I have tried to write a custom csv reader, but that also requires static filepath.