Getting variables from pom.xml java -
Getting variables from pom.xml java -
i using eclipse maven mobile automation test on mobile webpage.
i defining next in pom.xml
<properties> <my_variable>www.google.com/</my_variable> </properties>
but when calling using
string testurl1 = system.getproperty("my_variable");
it seems homecoming null.
i tried next way of defining variable
<plugin> <groupid>org.apache.maven.plugins</groupid> <artifactid>maven-surefire-plugin</artifactid> <version>2.16</version> <configuration> <systempropertyvariables> <my_variable>www.google.com</my_variable> </systempropertyvariables> </configuration> </plugin>
but still getting value null.
i utilize help thanks.
your configuration not work in eclipse since there no m2e back upwards surefire. maven surefire plugin forkes new process , provides systempropertyvariables
it. configuration work if run tests command-line, e.g.
mvn surefire:test
to create run in both worlds (command-line , eclipse) way...
createsrc/test/resources/maven.properties
edit maven.properties
file , set properties need in it, e.g.
project.build.directory=${project.build.directory} my_variable=${my_variable}
enable resource filtering test resources
<build> <testresources> <testresource> <directory>src/test/resources</directory> <filtering>true</filtering> </testresource> </testresources> ... </build>
load properties in test , access them
properties mavenprops = new properties(); inputstream in = testclass.class.getresourceasstream("/maven.properties"); mavenprops.load(in); string builddir = mavenprops.getproperty("project.build.directory"); string myvar = mavenprops.getproperty("my_variable");
java xml eclipse maven
Comments
Post a Comment