Friday, 15 June 2012

java - How to create maven profile & run each profile with different XML suites according to the profile activated? -



java - How to create maven profile & run each profile with different XML suites according to the profile activated? -

i'm new maven , maven profiles. i'm working on automation maven project , i'm trying create different profiles. want each profile run different xmlsuites according profile activated.

<profiles> <profile> <id>jenkins</id> <activation> <activebydefault>false</activebydefault> </activation> <build> <plugins> <plugin> <groupid>org.apache.maven.plugins</groupid> <artifactid>maven-surefire-plugin</artifactid> <version>2.17</version> <configuration> <includes> <include>**/*.java</include> </includes> <suitexmlfiles> <echo>jenkins profile</echo> <suitexmlfiles>xml/jenkins.xml</suitexmlfiles> </suitexmlfiles> </configuration> </plugin> </plugins> </build> </profile> <profile> <id>ticket</id> <activation> <activebydefault>false</activebydefault> </activation> <build> <plugins> <plugin> <groupid>org.apache.maven.plugins</groupid> <artifactid>maven-surefire-plugin</artifactid> <version>2.17</version> <configuration> <includes> <include>**/*.java</include> </includes> <suitexmlfiles> <echo>ticket profile</echo> <suitexmlfiles>xml/tickets.xml</suitexmlfiles> </suitexmlfiles> </configuration> </plugin> </plugins> </build> </profile> </profiles>

above have done. hope give me hand in giving me pointers on how it.

now i'm getting next error when running automation on jenkins:

[error] failed execute goal org.apache.maven.plugins:maven-surefire- plugin:2.17:test (default-test) on project ipos: execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.17:test failed: there error in forked process [error] org.apache.maven.surefire.testset.testsetfailedexception: suite file c:\program files (x86)\jenkins\workspace\automatizacion ipos\ticket profile not valid file [error] @ org.apache.maven.surefire.testng.testngxmltestsuite.locatetestsets(testngxmltestsuite.java:116) [error] @ org.apache.maven.surefire.testng.testngprovider.invoke(testngprovider.java:84) [error] @ org.apache.maven.surefire.booter.forkedbooter.invokeproviderinsameclassloader(forkedbooter.java:200) [error] @ org.apache.maven.surefire.booter.forkedbooter.runsuitesinprocess(forkedbooter.java:153) [error] @ org.apache.maven.surefire.booter.forkedbooter.main(forkedbooter.java:103) [error] -> [help 1] [error] [error] see total stack trace of errors, re-run maven -e switch. [error] re-run maven using -x switch enable total debug logging. [error] [error] more info errors , possible solutions, please read next articles:

thanks

then cleanest implementation have single configuration of plugin run every build, , define property token varies 1 profile next.

<profiles> <profile> <id>jenkins</id> <properties> <my.echo>jenkins profile</my.echo> <my.xml.files>xml/jenkins.xml</my.xml.files> </properties> </profile> <profile> <id>ticket</id> <properties> <my.echo>ticket profile</my.echo> <my.xml.files>xml/tickets.xml</my.xml.files> </properties> </profile> </profiles> <build> <plugins> <plugin> <groupid>org.apache.maven.plugins</groupid> <artifactid>maven-surefire-plugin</artifactid> <version>2.17</version> <configuration> <includes> <include>**/*.java</include> </includes> <suitexmlfiles> <!-- delete line: typo <echo>ticket profile</echo> --> <!-- profile-driven substitution --> <echo>${my.echo}</echo> <suitexmlfiles>${my.xml.files}</suitexmlfiles> </suitexmlfiles> </configuration> </plugin> </plugins> </build>

hope helps.

java maven selenium-webdriver

No comments:

Post a Comment