Javix
2012-09-25 08:58:11 UTC
What is the best way to load properties file so that to use needed
properties (like host url user name, etc.) all around the steps definitions
when using Selenium WebDriver?.
I define some profiles in POM file as follows:
...
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<cucumber.options>--format pretty</cucumber.options>
</properties>
<profiles>
<profile>
<id>dev</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<host>htp:some.host</host>
<admin.username>dmin</admin.username>
<admin.password>dmin</admin.password>
</properties>
</profile>
<profiles>
....
I created a property file names app.properties in my_app/src/main/resources.
And then I'd like to get a property as follows (by calling somewhere the
'initProperties' method):
private Properties properties;
private void initProperties(){
properties = new Properties();
try {
properties.load(getClass().getResourceAsStream("/app.properties"));
} catch (IOException ex) {
Logger.getLogger(MyClass.class.getName()).log(Level.SEVERE,
null, ex);
}
}
If I define the 'initProperties' method in a 'before' hook somewhere, so it
will be run before each scenario? Right? It seems as not very perfect, as
normally, the properties should be loaded only once.
Thank you.
properties (like host url user name, etc.) all around the steps definitions
when using Selenium WebDriver?.
I define some profiles in POM file as follows:
...
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<cucumber.options>--format pretty</cucumber.options>
</properties>
<profiles>
<profile>
<id>dev</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<host>htp:some.host</host>
<admin.username>dmin</admin.username>
<admin.password>dmin</admin.password>
</properties>
</profile>
<profiles>
....
I created a property file names app.properties in my_app/src/main/resources.
And then I'd like to get a property as follows (by calling somewhere the
'initProperties' method):
private Properties properties;
private void initProperties(){
properties = new Properties();
try {
properties.load(getClass().getResourceAsStream("/app.properties"));
} catch (IOException ex) {
Logger.getLogger(MyClass.class.getName()).log(Level.SEVERE,
null, ex);
}
}
If I define the 'initProperties' method in a 'before' hook somewhere, so it
will be run before each scenario? Right? It seems as not very perfect, as
normally, the properties should be loaded only once.
Thank you.
--
-- Rules --
1) Please prefix the subject with [Ruby], [JVM] or [JS].
2) Please use interleaved answers http://en.wikipedia.org/wiki/Posting_style#Interleaved_style
3) If you have a question, don't reply to an existing message. Start a new topic instead.
You received this message because you are subscribed to the Google Groups Cukes group. To post to this group, send email to cukes-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org To unsubscribe from this group, send email to cukes+***@googlegroups.com. For more options, visit this group at https://groups.google.com/d/forum/cukes?hl=en
-- Rules --
1) Please prefix the subject with [Ruby], [JVM] or [JS].
2) Please use interleaved answers http://en.wikipedia.org/wiki/Posting_style#Interleaved_style
3) If you have a question, don't reply to an existing message. Start a new topic instead.
You received this message because you are subscribed to the Google Groups Cukes group. To post to this group, send email to cukes-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org To unsubscribe from this group, send email to cukes+***@googlegroups.com. For more options, visit this group at https://groups.google.com/d/forum/cukes?hl=en