Testing JakartaEE applications with Arquillian Payara Micro Remote - maven

I'm trying to test a JakartaEE application with Arquillian in Maven. Since the productive application should be running on Payara Micro, I chose the Payara Micro Remote dependency for the communication with the remote server:
<dependencies>
<dependency>
<groupId>org.jboss.arquillian.junit</groupId>
<artifactId>arquillian-junit-container</artifactId>
<version>1.6.0.Final</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>fish.payara.arquillian</groupId>
<artifactId>payara-micro-remote</artifactId>
<version>2.2</version>
<scope>test</scope>
/dependency>
</dependencies>
When I executed the tests, I got the following error:
[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 1.325 s <<< FAILURE! - in com.mycompany.SomeTestClass
[ERROR] com.mycompany.SomeTestClass Time elapsed: 1.325 s <<< ERROR!
java.lang.IllegalArgumentException: Deployment failed. Payara Micro Deployer at http://localhost:8080/micro-deployer returned 404
I also tried deploying Payara Micro Deployer to the remote Payara Micro Server like follows:
<plugin>
<groupId>fish.payara.maven.plugins</groupId>
<artifactId>payara-micro-maven-plugin</artifactId>
<version>1.0.7</version>
<configuration>
<daemon>true</daemon>
<commandLineOptions>
<commandLineOption>
<key>--deployFromGAV</key>
<value>"fish.payara.arquillian,payara-micro-deployer,2.2"</value>
</commandLineOption>
</commandLineOptions>
</configuration>
<!-- ...some cother settings... -->
</plugin>
But this resulted in
[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 1.34 s <<< FAILURE! - in com.mycompany.SomeTestClass
[ERROR] com.mycompany.SomeTestClass Time elapsed: 1.34 s <<< ERROR!
java.lang.IllegalArgumentException: Deployment failed. Payara Micro Deployer at http://localhost:8080/micro-deployer returned 403
What am I doing wrong? Is there any description or example project on how to get Arquillian with Payara Micro Remote working?
The Payara Micro version I'm using is 5.194.
Thank you in advance!

After checking the Payara Micro's deployed paths, which were
GET /payara-micro-deployer/application.wadl
DELETE /payara-micro-deployer/application/{name}
PUT /payara-micro-deployer/application/{name}
and digging into the source code of Payara Micro Remote connector's configuration (https://github.com/payara/ecosystem-arquillian-connectors/blob/master/payara-micro-remote/src/main/java/fish/payara/arquillian/container/payaramicro/remote/PayaraMicroRemoteContainerConfiguration.java)
/**
* Get path payara-micro-deployer resides at.
* #return
*/
public String getDeployerContextPath() {
return deployerContextPath;
}
I found the solution.
I had to configure Payara Micro's deployment path in the arquillian.xml as follows:
<configuration>
<property name="deployerContextPath">/payara-micro-deployer</property>
</configuration>

Related

Tycho integration test are not run (but Unit tests are..)

I have a multi module project with a plugin and fragment to test this plugin.
The build is done through maven/tycho. Maven v.3.8.4 and Tycho v2.6.0.
In the fragment I have 3 Unit and 1 Integration test, in the test folder:
test
├── CoreTestConstants.java
├── CoreUtils2Test.java
├── CoreUtils3Test.java
├── CoreUtilsIT.java
└── CoreUtilsTest.java
This is the pom of the fragment plugin:
<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>
<artifactId>com.tycho.rcp.core.test</artifactId>
<version>0.2.4-SNAPSHOT</version>
<packaging>eclipse-test-plugin</packaging>
<parent>
<groupId>com.tycho</groupId>
<artifactId>com.tycho.mps</artifactId>
<version>0.3.4-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-surefire-plugin</artifactId>
<executions>
<execution>
<id>it-test</id>
<phase>integration-test</phase>
<goals>
<goal>integration-test</goal>
</goals>
</execution>
</executions>
<configuration>
<testSourceDirectory>src</testSourceDirectory>
<testClassesDirectory>target/classes</testClassesDirectory>
<!-- workspace directory -->
<osgiDataDirectory>${mas.test.workspace}</osgiDataDirectory>
<!-- system properties -->
<systemProperties>
<mas.test.archive_location>${mas.test.archive_location}</mas.test.archive_location>
</systemProperties>
<!-- add slf4j implementation dependency from Orbit -->
<dependencies>
<dependency>
<groupId>org.eclipse.orbit.bundles</groupId>
<artifactId>ch.qos.logback.slf4j</artifactId>
<version>1.1.2</version>
<type>eclipse-plugin</type>
</dependency>
</dependencies>
</configuration>
</plugin>
</plugins>
</build>
</project>
The tycho-surefire-plugin is enabled in pluginManagement of the parent project:
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-surefire-plugin</artifactId>
<version>${tycho.version}</version>
</plugin>
The 3 Unit test are executed correctly, but the IT test is never run!
This is the relevant part of the output, when I run mvn clean verify inside the fragment project:
[INFO] --- tycho-surefire-plugin:2.6.0:test (default-test) # com.marchesini.mas.rcp.core.test ---
[INFO] Executing Test Runtime with timeout 0, logs (if any) will be placed at: /home/gionata/runtime-EclipseApplication/.metadata/.log
[INFO] Command line:
[/usr/lib/jvm/java-11-openjdk-11.0.9.11-0.fc31.x86_64/bin/java, -Dosgi.noShutdown=false, -Dosgi.os=linux, -Dosgi.ws=gtk, -Dosgi.arch=x86_64, -Dosgi.clean=true, -Dmas.test.archive_location=/home/gionata/ARCHIVIO.BLK, -jar, /home/gionata/.m2/repository/p2/osgi/bundle/org.eclipse.equinox.launcher/1.5.100.v20180827-1352/org.eclipse.equinox.launcher-1.5.100.v20180827-1352.jar, -data, /home/gionata/runtime-EclipseApplication, -install, /home/gionata/Workspace_Eclipse_Maven/MAS/MPS/com.marchesini.mas.rcp.core.test/target/work, -configuration, /home/gionata/Workspace_Eclipse_Maven/MAS/MPS/com.marchesini.mas.rcp.core.test/target/work/configuration, -application, org.eclipse.tycho.surefire.osgibooter.headlesstest, -testproperties, /home/gionata/Workspace_Eclipse_Maven/MAS/MPS/com.marchesini.mas.rcp.core.test/target/surefire.properties]
Running com.marchesini.mas.rcp.core.test.CoreUtils2Test
Logger launcher start...4
2022-02-05 18:36:11,221 DEBUG [main]: CHECKSUM 2 = 340351cde832c00505c88f3fe1a962d4
2022-02-05 18:36:11,442 DEBUG [main]: Workspace = /home/gionata/runtime-EclipseApplication
2022-02-05 18:36:11,442 DEBUG [main]: Archive location = /home/gionata/ARCHIVIO.BLK
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.569 s - in com.marchesini.mas.rcp.core.test.CoreUtils2Test
testCoreUtils2(com.marchesini.mas.rcp.core.test.CoreUtils2Test) Time elapsed: 0.226 s
Running com.marchesini.mas.rcp.core.test.CoreUtilsTest
#################################################################################
REPORT
CHECKSUM = 340351cde832c00505c88f3fe1a962d4
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.003 s - in com.marchesini.mas.rcp.core.test.CoreUtilsTest
testCoreUtils(com.marchesini.mas.rcp.core.test.CoreUtilsTest) Time elapsed: 0.002 s
Running com.marchesini.mas.rcp.core.test.CoreUtils3Test
Logger launcher start...4
2022-02-05 18:36:11,537 DEBUG [main]: CHECKSUM 3 = 340351cde832c00505c88f3fe1a962d4
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.024 s - in com.marchesini.mas.rcp.core.test.CoreUtils3Test
testCoreUtils3(com.marchesini.mas.rcp.core.test.CoreUtils3Test) Time elapsed: 0.001 s
Results:
Tests run: 3, Failures: 0, Errors: 0, Skipped: 0
[INFO] All tests passed!
[INFO]
[INFO] --- tycho-surefire-plugin:2.6.0:integration-test (it-test) # com.marchesini.mas.rcp.core.test ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
The execution it-test simply doesn't run anything! I have been wasting hours on this....
Thankyou for any help.
First of all, you shouldn't add any specific configuration if you follow the default conventions. Moreover, parameters like <testSourceDirectory>src</testSourceDirectory> are not read by the tycho surefire plugin. Moreover, there's no need to create products or features for what you need. The reason why it's not working it's because of a bug:
https://github.com/eclipse/tycho/issues/643
On a side note, I've updated the RELEASE notes
https://github.com/eclipse/tycho/pull/641
trying to document better the rationale behind the new goal (but, again, it does not work due to a bug)

How do I get Maven to print out the test names that failed?

I'm using Maven 3.0.3, JUnit 4.8.1, and Spring 3.1.1.RELEASE. I have my Surefire plugin configured this way
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.14.1</version>
<configuration>
<reuseForks>false</reuseForks>
<argLine>-Xmx2048m -XX:MaxPermSize=512M</argLine>
</configuration>
</plugin>
I notice when my unit tests fail because of IllegalStateExceptions, Maven never prints out the test names that failed at the end of execution. Instead I'll see
mvn clean install
...
Tests in error:
? IllegalState Failed to load ApplicationContext
? IllegalState Failed to load ApplicationContext
? IllegalState Failed to load ApplicationContext
? IllegalState Failed to load ApplicationContext
How can I get Mavne to print out more specific info about test failures? Right now I have to go digging through the surefire-reports directory to figure out what failed. Most of my JUnit tests look like this:
#RunWith(SpringJUnit4ClassRunner.class)
#ContextConfiguration({ "classpath:test-context.xml" })
public class CleverTeacherServiceTest extends AbstractImportServiceTest
{
I think your Spring test config is failing before your tests run. You should normally see the failed tests listed in the console, like:
T E S T S
Running TestSuite
..
Tests run: 234, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 7.019 sec <<< FAILURE!
fooTest(BarTest) Time elapsed: 0.011 sec <<< FAILURE!
fooTest(BarTest.java:23)
Results :
Failed tests:
BarTest.fooTest:23 null
Tests run: 234, Failures: 1, Errors: 0, Skipped: 0
You could run your tests setting the surefire plugin property useFile == false to have all the plugin output sent to the console. I wouldn't configure that in the pom file, but run it like so:
mvn -Dsurefire.useFile=false clean test
See Surefire Plugin docs for config information.

Maven surefire 2.12 does not run a specific test using -Dtest parameter

After upgrading all my Maven plugins version for a project, I encountered the following problem: when I run the basic command mvn test -Dtest=SomeTest, the build finishes with no test executed at all. In fact, I am not able to run any test using -Dtest parameter (of course the test exist, and is run when I simply execute mvn test).
After some searches, it appears that the problem is due to the usage of surefire 2.12 plugin. I've tested several versions of Maven (2.2.1 / 3.0.2) and JUnit (4.7.x, 4.8, 4.10, or even 3.8.x), but they have no impact on my issue.
So maybe my project has some specific configurations that may have an impact on that? Anyway, I created a new project, using mvn archetype:generate (using the basic org.apache.maven.archetypes:maven-archetype-quickstart).
I modified only 2 things in the pom.xml: using JUnit 4.10 (but it didn't change anything, I've tried with others versions), and defining the version of surefire:
<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>foo</groupId>
<artifactId>bar</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.11</version>
</plugin>
</plugins>
</build>
</project>
I run mvn test -Dtest=AppTest (the default JUnit test created by the archetype):
------------------------------------------------------- T E S T S
------------------------------------------------------- Running foo.AppTest Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time
elapsed: 0.031 sec
Results :
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
[INFO]
------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO]
Now, I modify the pom.xml to use version 2.12 for Surefire and run the command again:
------------------------------------------------------- T E S T S
Results :
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO]
------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO]
------------------------------------------------------------------------ [INFO] Total time: 0.907s [INFO] Finished at: Fri Mar 02 10:37:12 CET
2012 [INFO] Final Memory: 3M/15M [INFO]
------------------------------------------------------------------------ [ERROR] Failed to execute goal
org.apache.maven.plugins:maven-surefire-plugin:2.12:test
(default-test) on project bar: No tests were executed! (Set -D
failIfNoTests=false to ignore this error.) -> [Help 1]
The test is not run this time :(
As far as I am concerned, I think it's a regression, but that's quite surprising. Indeed, a JIRA defect is logged on Surefire 2.12 version, and in this description, they succeed in using -Dtest parameter.
Am I doing something wrong? Or is it a real regression (in this case, I will create the JIRA)?
Thanks.
It's a bug in 2.12 version - SUREFIRE-827.

Unable to deploy to Tomcat7 from cargo

I'm trying to deploy to a remote Tomcat7 with Cargo from Maven over https.
I've set up manager-script role and I've succeeded so far as to have been able to undeploy an app remotely.
What I have looks like this:
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.1.2</version>
<configuration>
<container>
<containerId>tomcat7x</containerId>
<type>remote</type>
</container>
<configuration>
<type>runtime</type>
<properties>
<cargo.remote.uri>https://xxx/manager/text</cargo.remote.uri>
<cargo.remote.username>${tomcat.username}</cargo.remote.username>
<cargo.remote.password>${tomcat.password}</cargo.remote.password>
</properties>
</configuration>
<deployer>
<type>remote</type>
<deployables>
<deployable>
<groupId>mycomp</groupId>
<artifactId>myartifact</artifactId>
<type>war</type>
<properties>
<context>/</context>
</properties>
</deployable>
</deployables>
</deployer>
</configuration>
</plugin>
Well, I know the credentials and everything is setup correctly, and I have used the new /text interface and I have been able to undeploy an existing app. But when trying to run deploy:
mvn cargo:deployer-deploy -e
I get an error with root cause:
Caused by: java.io.IOException: Error writing request body to server
at sun.net.www.protocol.http.HttpURLConnection$StreamingOutputStream.checkError(HttpURLConnection.java:2809)
at sun.net.www.protocol.http.HttpURLConnection$StreamingOutputStream.write(HttpURLConnection.java:2792)
at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:65)
at java.io.BufferedOutputStream.write(BufferedOutputStream.java:109)
at org.codehaus.cargo.container.tomcat.internal.TomcatManager.pipe(TomcatManager.java:605)
at org.codehaus.cargo.container.tomcat.internal.TomcatManager.invoke(TomcatManager.java:501)
at org.codehaus.cargo.container.tomcat.internal.TomcatManager.deployImpl(TomcatManager.java:569)
at org.codehaus.cargo.container.tomcat.internal.TomcatManager.deploy(TomcatManager.java:273)
at org.codehaus.cargo.container.tomcat.internal.TomcatManager.deploy(TomcatManager.java:256)
at org.codehaus.cargo.container.tomcat.internal.TomcatManager.deploy(TomcatManager.java:240)
at org.codehaus.cargo.container.tomcat.internal.AbstractTomcatManagerDeployer.deploy(AbstractTomcatManagerDeployer.java:101)
... 25 more
I get it quite immediately so it can't be a timeout.
Can the file be to large? It's a 60 MB war. I made sure my nginx allows bigger:
client_max_body_size 200M;
I also added multipart config to the text manager in the manager webapps web.xml like this:
servlet>
Manager
org.apache.catalina.manager.ManagerServlet
debug
2
<multipart-config>
<max-file-size>209715200</max-file-size>
<max-request-size>209715200</max-request-size>
<file-size-threshold>0</file-size-threshold>
</multipart-config>
http://nexnet.wordpress.com/2011/04/27/large-war-file-cannot-be-deployed-in-tomcat-7/
I love Maven in many ways, but the error reporting is really terrible. Any help highly appreciated.
I was bitten by this error recently, when I tried to cargo:deploy an artifact. Usually we stop, clean and start the webapps directory before deploying, but this time I noticed that one artifact was not removed.
After switching to cargo:redeploy the error was solved.
I ran into this same error message when deploying to a tomcat 8 server using the ant deploy task. The issue in my case was that I was running out of space on the server. Checking tomcat's manager log is what clued me in:
10-Jul-2014 10:15:38.065 INFO [http-nio-8080-exec-2] org.apache.catalina.core.ApplicationContext.log Manager: deploy: Deploying web application '/abc_beta'
10-Jul-2014 10:15:38.065 INFO [http-nio-8080-exec-2] org.apache.catalina.core.ApplicationContext.log Manager: Uploading WAR file to /usr/share/apache-tomcat-8.0.9/webapps/abc_beta.war
10-Jul-2014 10:15:57.962 SEVERE [http-nio-8080-exec-2] org.apache.catalina.core.ApplicationContext.log Manager: managerServlet.check[/abc_beta]
java.io.IOException: No space left on device
... stacktrace ...
I don't remember if or how I solved this, but as rascio has the same problem, I'll post a an idea. Maybe it's the wagon-extension for ssl that's needed:
<extensions>
<extension>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-ssh</artifactId>
<version>2.2</version>
</extension>
</extensions>
Wild guess though. I think you didn't need it before Maven 3.0.
Another reason for this exception that we stumbled upon suddenly on monday, when deployment jobs on our Jenkins instance using the cargo plugin plugin stopped working. Not all of them, but some. The main difference was a a custom settings.xml in the jobs for a Nexus repository to download deployables from.
The successful deployment jobs had it configured like described in https://support.sonatype.com/entries/20943003-configure-maven-to-download-from-nexus, the failed ones were missing the repository and pluginRepository
I'm still not sure why the behavior changed at one point. Any tipps?

springTestContextBeforeTestMethod failed in Maven spring-test

I try to setup a project with spring-test using TestNg in Maven. The code is like:
#ContextConfiguration(locations={"test-context.xml"})
public class AppTest extends AbstractTestNGSpringContextTests {
#Test
public void testApp() {
assert true;
}
}
A test-context.xml simply defined a bean:
<bean id="app" class="org.sonatype.mavenbook.simple.App"/>
I got error for Failed to load ApplicationContext when running mvn test from command line, seems it cannot find the test-context.xml file; however, I can get it run correctly inside Eclipse (with TestNg plugin).
So, test-context.xml is under src/test/resources/, how do I indicate this in the pom.xml so that 'mvn test' command will work?
Thanks,
UPDATE:
Thanks for the reply. Cannot load context file error was caused by I moved the file arround in different location since I though the classpath was the problem. Now I found the context file seems loaded from the Maven output, but the test is failed:
Running TestSuite
May 25, 2010 9:55:13 AM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource [test-context.xml]
May 25, 2010 9:55:13 AM org.springframework.context.support.AbstractApplicationContext prepareRefresh
INFO: Refreshing org.springframework.context.support.GenericApplicationContext#171bbc9: display name [org.springframework.context.support.GenericApplicationContext#171bbc9]; startup date [Tue May 25 09:55:13 PDT 2010]; root of context hierarchy
May 25, 2010 9:55:13 AM org.springframework.context.support.AbstractApplicationContext obtainFreshBeanFactory
INFO: Bean factory for application context [org.springframework.context.support.GenericApplicationContext#171bbc9]: org.springframework.beans.factory.support.DefaultListableBeanFactory#1df8b99
May 25, 2010 9:55:13 AM org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons
INFO: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory#1df8b99: defining beans [app,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor]; root of factory hierarchy
Tests run: 3, Failures: 2, Errors: 0, Skipped: 1, Time elapsed: 0.63 sec <<< FAILURE!
Results :
Failed tests:
springTestContextBeforeTestMethod(org.sonatype.mavenbook.simple.AppTest)
springTestContextAfterTestMethod(org.sonatype.mavenbook.simple.AppTest)
Tests run: 3, Failures: 2, Errors: 0, Skipped: 1
If I use spring-test version 3.0.2.RELEASE, the error becomes:
org.springframework.test.context.testng.AbstractTestNGSpringContextTests.springTestContextPrepareTestInstance() is depending on nonexistent method null
Here is the structure of the project:
simple
|-- pom.xml
`-- src
|-- main
| `-- java
`-- test
|-- java
`-- resources
|-- test-context.xml
`-- testng.xml
testng.xml:
<suite name="Suite" parallel="false">
<test name="Test">
<classes>
<class name="org.sonatype.mavenbook.simple.AppTest"/>
</classes>
</test>
</suite>
test-context.xml:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd"
default-lazy-init="true">
<bean id="app" class="org.sonatype.mavenbook.simple.App"/>
</beans>
In the pom.xml, I add testng, spring, and spring-test artifacts, and plugin:
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>5.1</version>
<classifier>jdk15</classifier>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring</artifactId>
<version>2.5.6</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>2.5.6</version>
<scope>test</scope>
</dependency>
<build>
<finalName>simple</finalName>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
</plugins>
Basically, I replaced 'A Simple Maven Project' Junit with TestNg, hope it works.
UPDATE:
I think I got the problem (still don't know why) -
Whenever I extends AbstractTestNGSpringContextTests or AbstractTransactionalTestNGSpringContextTests, the test will failed with this error:
Failed tests:
springTestContextBeforeTestMethod(org.sonatype.mavenbook.simple.AppTest)
springTestContextAfterTestMethod(org.sonatype.mavenbook.simple.AppTest)
So, eventually the error went away when I override the two methods.
I don't think this is the right way, didn't find much info from spring-test doc.
If you know spring test framework, please shred some light on this.
Add classpath in front of the filename. Then it will search in the root folder of all source folders.
#ContextConfiguration(locations={"classpath:test-context.xml"})
I had the same problem with Spring 2.5.6. I solved using testng 5.5.
The version I was using (testng 5.1) had the same behavior: the test runs fine inside of Eclipse, but it can not find the context from the command line.
Replacing testng with testng 2.5.6 the problem is gone. The is valid only with Spring 2.5.6
A shot in the dark, since I haven't seen your Java code: are you sure you are using #BeforeMethod and not #BeforeTest?

Resources