I have a web application named as GroupWebApplication. Using pom.xml file I'm just creating the war of my application and deploying to tomcat server. This is basically a maven project. I have added plugins for tomcat7 apache server.
Now what I want that I want to start the tomcat server then run the integration tests and after the completion of the integration tests I want to stop the server. Basically I'm using the testng.xml file of TestNg framework.testng.xml files contains all the classes for integration tests. Manually it's working fine, i.e. starting the server manually and running the test.
Here is the pom file:
<dependencies>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.3.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<finalName>sGroupWebApplication Integration Test</finalName>
<resources>
<resource>
<directory>src/main/resources</directory>
</resource>
</resources>
<pluginManagement>
<plugins>
<!-- Maven Tomcat Plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<id>resource-dependencies</id>
<phase>initialize</phase>
<goals>
<goal>unpack-dependencies</goal>
</goals>
<configuration>
<includeGroupIds>com.company.integration.test</includeGroupIds>
<includeArtifactIds>engine</includeArtifactIds>
<includes>**\/*.xpi,**\/*.exe,**\/*.so, **\/*.ftl,**\/*.css,**\/*.woff, **\/*.properties,**\/*.png,**\/chromedriver,**\/*.MF</includes>
<outputDirectory>${project.build.directory}/classes</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.0</version>
<configuration>
<url>http://localhost:8080/manager/text</url>
<server>localhost</server>
<path>/GroupWebApplication</path>
<username>admin</username>
<password>s3cret</password>
</configuration>
<executions>
<execution>
<id>tomcat7-run</id>
<goals>
<goal>run-war-only</goal>
</goals>
<phase>pre-integration-test</phase>
<configuration>
<fork>true</fork>
</configuration>
</execution>
<execution>
<id>tomcat7-shutdown</id>
<goals>
<goal>shutdown</goal>
</goals>
<phase>post-integration-test</phase>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.4.2</version>
</plugin>
<!-- Java compiler version -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>${target.jdk}</source>
<target>${target.jdk}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<configuration>
<archive>
<manifestEntries>
<Project-Name>Integration App</Project-Name>
<Build-Version>${project.version}</Build-Version>
<Build-Date>${maven.build.timestamp}</Build-Date>
</manifestEntries>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.0</version>
<configuration>
<outputEncoding>UTF-8</outputEncoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9.1</version>
<configuration>
<reportOutputDirectory>javadoc</reportOutputDirectory>
<destDir>javadoc</destDir>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
testng.xml:
<suite name="INTEGRATION TEST Suite">
<parameter name="logging" value="SEVERE"/>
<test name="GrpApiTest">
<classes>
<class name="com.company.integration.test.DummyIT"></class>
</classes>
</test>
</suite>
The error that I'm getting:
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @
GroupWebApplication ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\Users\t_ddbc\Documents\clone_4_ju
ne\demo\GroupWebApplication\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @
GroupWebApplication
---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 6 source files to C:\Users\t_ddbc\Documents\clone_4_june\demo\
GroupWebApplication\target\test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ GroupWebApplication
---
[INFO] Surefire report directory:
C:\Users\t_ddbc\Documents\clone_4_june\demo\GroupWebApplication\target\surefire-
reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running TestSuite
Configuring TestNG with: org.apache.maven.surefire.testng.conf.TestNGMapConfigur
ator@203e25d3
org.apache.maven.surefire.util.SurefireReflectionException: java.lang.reflect.In
vocationTargetException; nested exception is java.lang.reflect.InvocationTargetE
xception: null
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(
ReflectionUtils.java:189)
at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke
(ProviderFactory.java:165)
at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(Provi
derFactory.java:85)
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(Fork
edBooter.java:115)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:
75)
Caused by: java.lang.IllegalStateException:
On the terminal command I'm using at the root of my project mvn verify
Basically this is duplicate of this question but it is not working for me.