RE: Getting error related to @Parameters annotation while using testNG with Maven

Hello,
I’m using testNG with Maven and facing an error related to @Parameters annotation. I’ve created a launch bowser method in my test case and passing parameter (eg: Firefox) to it from testng.xml using @Parameters annotation.  I’ve mentioned the correct testNG.xml path in pom.xml and when run it as Maven test, I’m getting the error message “Parameter ‘browser’ is required by @Configuration on method launchPage but has not been marked @Optional or defined”. When I run testNG.xml file as a TestNGsuite (not as Maven test), it is working perfectly.  As per the error message I’ve included @Optional parameter and passed the hard coded browser value as ‘Firefox’ in the same above launch browser method (which shouldn’t be done as per my knowledge), in this case I’m not getting any error message but pom.xml is not recognizing and running testNG.xml (I was already appended my test cases with ‘Test’ at the end). Below is the pom.xml code. Please suggest any solutions. Many Thanks in advance.

<project xmlns=”http://maven.apache.org/POM/4.0.0″ xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”
xsi:schemaLocation=”http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd”>
<modelVersion>4.0.0</modelVersion>

<groupId>com.wordPress.maven</groupId>
<artifactId>WordPressMaven</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>WordPressMaven-build</name>
<url>http://maven.apache.org</url>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<build>
<!– sourceDirectory>src/test/resources</sourceDirectory –>
<!– To define the plugin version in your parent POM –>
<pluginManagement>
<plugins>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>2.12.2</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>src/test/resources/suites-test-testng.xml</suiteXmlFile>
</suiteXmlFiles>
<parallel>methods</parallel>
<threadCount>5</threadCount>

</configuration>
</plugin>

<!–
plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<encoding>iso-8859-1</encoding>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
–>

</plugins>
</pluginManagement>
</build>

<dependencies>

<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.8.8</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.45.0</version>
</dependency>

<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-server</artifactId>
<version>2.45.0</version>
</dependency>

<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.10-FINAL</version>
</dependency>

<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-api</artifactId>
<version>2.18.1</version>
</dependency>

<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>3.3.1</version>
</dependency>

</dependencies>

<reporting>
<plugins>
<!– TestNG-xslt related configuration. –>
<plugin>
<groupId>org.reportyng</groupId>
<artifactId>reporty-ng</artifactId>
<version>1.2</version>
<configuration>
<!– Output directory for the testng xslt report –>
<outputDir>/target/testng-xslt-report/index.html</outputDir>
<sortTestCaseLinks>true</sortTestCaseLinks>
<testDetailsFilter>FAIL,SKIP,PASS,CONF,BY_CLASS</testDetailsFilter>
<showRuntimeTotals>true</showRuntimeTotals>
</configuration>
</plugin>
</plugins>
</reporting>

<pluginRepositories>
<pluginRepository>
<id>reporty-ng</id>
<url>https://github.com/cosminaru/reporty-ng/raw/master/dist/maven</url>
</pluginRepository>
</pluginRepositories>

</project>

Add Comment
4 Answers

Hello Virender,

Could you please take time to have a look into above issue as it is not resolved by me.

Many Thanks
Pavan

Train Answered on March 26, 2015.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.