testing - Maven execution of single attached test -


i'm relatively new maven , have been struggling attached tests, i've found few articles here have got me part of way there can't quite last little bit. here i'm trying do. have 2 modules 1 defines set of interfaces , rudimentary test of interfaces. second module provides implementation of interface , i'd run predefined test on it. boiled down simple example, here 2 projects:

interface  + pom.xml  + src     + main        + java           + demo              + messenger.java     + test        + java           + demo              + messengertest.java  impl  + pom.xml  + src     + main        + java           + demo              + impl                 + messengerimpl.java     + test        + resources           + context.xml 

the interface pom.xml:

<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">   <groupid>demo</groupid>   <artifactid>interface</artifactid>   <version>1.0</version>   <modelversion>4.0.0</modelversion>   <packaging>jar</packaging>    <dependencies>     <dependency>       <groupid>junit</groupid>       <artifactid>junit</artifactid>       <version>4.11</version>     </dependency>     <dependency>       <groupid>org.springframework</groupid>       <artifactid>spring-context</artifactid>       <version>3.2.2.release</version>     </dependency>   </dependencies>   <build>     <plugins>       <plugin>         <groupid>org.apache.maven.plugins</groupid>         <artifactid>maven-surefire-plugin</artifactid>         <version>2.14</version>         <configuration>           <skiptests>true</skiptests>         </configuration>       </plugin>       <plugin>         <groupid>org.apache.maven.plugins</groupid>         <artifactid>maven-jar-plugin</artifactid>         <version>2.2</version>         <executions>           <execution>             <goals>               <goal>test-jar</goal>             </goals>           </execution>         </executions>       </plugin>     </plugins>   </build> </project> 

the messenger.java source:

package demo;  public interface messenger {     string getmessage(); } 

the messengertest.java source:

package demo;  import static org.junit.assert.assertnotnull; import static org.junit.assert.asserttrue;  import org.junit.before; import org.junit.test; import org.springframework.beans.factory.beanfactory; import org.springframework.context.support.classpathxmlapplicationcontext;  import demo.messenger;  public class messengertest {     private beanfactory beanfactory;      @before     public void setup() throws exception {         beanfactory = new classpathxmlapplicationcontext("context.xml");     }      @test     public final void testgetmessage() throws exception {         final messenger msngr = beanfactory.getbean(messenger.class);         string msg = msngr.getmessage();         assertnotnull(msg);         asserttrue(msg.length() > 0);     } } 

executing 'mvn install' appears right thing creating interface-1.0.jar , interface-1.0-tests.jar in local repository.

the implementation code simple, pom.xml:

<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">   <groupid>demo</groupid>   <artifactid>impl</artifactid>   <version>1.0</version>   <modelversion>4.0.0</modelversion>   <packaging>jar</packaging>    <dependencies>     <dependency>       <groupid>demo</groupid>       <artifactid>interface</artifactid>       <version>1.0</version>     </dependency>     <dependency>       <groupid>demo</groupid>       <artifactid>interface</artifactid>       <version>1.0</version>       <type>test-jar</type>       <scope>test</scope>     </dependency>   </dependencies>  </project> 

the messageimpl.java source:

package demo.impl;  import demo.messenger;  public class messengerimpl implements messenger {      @override     public string getmessage() {         return "hello world";     } } 

and finally, spring context file:

<?xml version="1.0" encoding="utf-8"?> <beans xmlns="http://www.springframework.org/schema/beans"         xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"         xmlns:aop="http://www.springframework.org/schema/aop"        xsi:schemalocation="http://www.springframework.org/schema/beans         http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">   <bean id="mymessenger" class="demo.impl.messengerimpl"/> </beans> 

with of in place execute 'mvn -dtest=demo.messengertest test', , unfortunately fails "... no tests executed!". there problem.

sorry, being long winded wanted complete, guidance appreciated.

surefire doesn't scan through classpath when deciding classes run, tests defined in same module considered. checks in target/classes in impl project, doesn't see tests, , ignores messengertest. define test suite in impl project references tests run, or unzip dependency target/classes.


Comments

Popular posts from this blog

ios - iPhone/iPad different view orientations in different views , and apple approval process -

java Extracting Zip file -

C# WinForm - loading screen -