A
A
Alena2015-02-12 12:47:16
Java
Alena, 2015-02-12 12:47:16

How to optimize a test?

I have a set of tests that are completely independent of each other and have a common logging item. How can I remove this logging and where, so that when I change the login, I don’t change 10 tests, but change only in one block?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
K
Kenshir007, 2015-08-21
@Kossmmooss

If we are talking about Java, then I advise PropertyLoader
public class PropertyLoader {
private static final String PROP_FILE = "/application.properties";
private PropertyLoader() {}
public static String loadProperty(String name) {
Properties props = new Properties();
try {
props.load(PropertyLoader.class.getResourceAsStream(PROP_FILE));
} catch (IOException e) {
e.printStackTrace();
}
String value = "";
if (name != null) {
value = props.getProperty(name);
}
return value;
}
}
you also need to create a file anyname.properties
and there set whatever you want an example:
user.username=${user.username}
user.password=${user.password}
grid2.hub= localhost:5555/wd/hub
site.url= yoursite.ru
browser.name= chrome
admin.login=anyuser
admin. pass=anypass

M
Maxim, 2015-02-12
@maximya

maybe look in the direction of aop?

J
jehord, 2015-07-18
@jehord

well, put your login into a global variable and substitute it where you need it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question