Reputation: 89
What are some recommended ways to store data for a java test framework using the page object model? For example, I have a login test scenario with a LoginPage page object and a LoginTest which uses the LoginPage to run tests. I say something like
public class LoginTest {
public void testLoginScenario() {
LoginPage page = new LoginPage(getDriver());
page.enterLoginInfo("username", "password");
}
}
I want to store the "username" and "password" constants somewhere, but I don't know what the best way to do this is. Should I create a data.properties file and read from that? Should I keep these stored as final static constants in some TestData java class? This is a very small amount of test data so I don't think I would go the route of storing in a database or CSV.
Upvotes: 2
Views: 700
Reputation: 764
Storing a small amount of data in the '.properties' file should be fine. Keep in mind you will have sensitive data in the file and you need to have a good protection for your source code repository (especially if you are testing production environment as well).
An alternative is to use system properties or a combination of both '.properties' file and system properties - in the latter case you would have defaults stored in the file but you have the ability to override them in your CI/CD pipeline (e.g. Jenkins job).
Upvotes: 2