You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by "Valluri, Sankar" <sa...@fairisaac.com> on 2008/05/30 00:13:49 UTC

maven2 with Junit 4 ignores @Test annotations


I am trying to use maven with Junit4 test cases. Eclipse runs these
tests just fine but maven doesn't recognize any of these tests.

Here is the code
import org.junit.Test;
import static org.junit.Assert.*;

public class AdditionTest {
	  private int x = 1;
	  private int y = 1;
	  
	  @Test 
	  public void addition() {
	    int z = x + y;
	    assertEquals(2, z);
	  }
}

POM file
	<dependencies>
  		<dependency>
  			<groupId>org.junit</groupId>
  			<artifactId>junit</artifactId>
  			<version>4.4</version>
  		</dependency>
  	</dependencies>

	<build>
		<plugins>
			<plugin>
	
<groupId>org.apache.maven.plugins</groupId>
	
<artifactId>maven-compiler-plugin</artifactId>
				<configuration>
					<source>1.5</source>
					<target>1.5</target>
				</configuration>
			</plugin>
			<plugin>
	
<groupId>org.apache.maven.plugins</groupId>
	
<artifactId>maven-surefire-plugin</artifactId>
				<version>2.4.3</version>
				<configuration>
					<includes>
	
<include>**/*Test.java</include>
					</includes>
				</configuration>
			</plugin>			
		</plugins>
	</build>

Thanks
Sankar


This email and any files transmitted with it are confidential, proprietary
and intended solely for the individual or entity to whom they are addressed.
If you have received this email in error please delete it immediately.


RE: maven2 with Junit 4 ignores @Test annotations

Posted by "Valluri, Sankar" <sa...@fairisaac.com>.
Thank you all for your help. It turned out to be I have corrupted Junit/4.4 repository which I got it from our internal repository. When I pointed the POM file to maven central repository, everything started working.

I am not sure why maven did not complain about the corrupted Junit folders. The folder was missing pom and sha1 files (the folder had only junit-4.4.jar).

-Sankar

-----Original Message-----
From: Bouiaw [mailto:bouiaw@gmail.com] 
Sent: Friday, May 30, 2008 3:35 AM
To: Maven Users List
Subject: Re: maven2 with Junit 4 ignores @Test annotations

Sorry, I did'nt see the pom.xml in your message ;-)

On Fri, May 30, 2008 at 9:33 AM, Bouiaw <bo...@gmail.com> wrote:
> This problem usually come from older release of surefire plugin, try
> to use the lastest (2.4.3) in you pom.
>
> On Fri, May 30, 2008 at 9:31 AM, Martin Höller <ma...@xss.co.at> wrote:
>> On Friday 30 May 2008 Martin wrote:
>>> Looks like you'll need TestDecorator class from junit-4.1
>>> http://www.jdocs.com/junit/4.1/junit/extensions/TestDecorator.html
>>
>> No, you don't need this!
>>
>> Your code  and POM looks ok, where did you put your test-classes? Should be
>> in src/test/java.
>>
>> What did you execute? 'mvn test' should compile and run your tests.
>>
>> hth,
>> - martin
>>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org

This email and any files transmitted with it are confidential, proprietary
and intended solely for the individual or entity to whom they are addressed.
If you have received this email in error please delete it immediately.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: maven2 with Junit 4 ignores @Test annotations

Posted by Bouiaw <bo...@gmail.com>.
Sorry, I did'nt see the pom.xml in your message ;-)

On Fri, May 30, 2008 at 9:33 AM, Bouiaw <bo...@gmail.com> wrote:
> This problem usually come from older release of surefire plugin, try
> to use the lastest (2.4.3) in you pom.
>
> On Fri, May 30, 2008 at 9:31 AM, Martin Höller <ma...@xss.co.at> wrote:
>> On Friday 30 May 2008 Martin wrote:
>>> Looks like you'll need TestDecorator class from junit-4.1
>>> http://www.jdocs.com/junit/4.1/junit/extensions/TestDecorator.html
>>
>> No, you don't need this!
>>
>> Your code  and POM looks ok, where did you put your test-classes? Should be
>> in src/test/java.
>>
>> What did you execute? 'mvn test' should compile and run your tests.
>>
>> hth,
>> - martin
>>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: maven2 with Junit 4 ignores @Test annotations

Posted by Bouiaw <bo...@gmail.com>.
This problem usually come from older release of surefire plugin, try
to use the lastest (2.4.3) in you pom.

On Fri, May 30, 2008 at 9:31 AM, Martin Höller <ma...@xss.co.at> wrote:
> On Friday 30 May 2008 Martin wrote:
>> Looks like you'll need TestDecorator class from junit-4.1
>> http://www.jdocs.com/junit/4.1/junit/extensions/TestDecorator.html
>
> No, you don't need this!
>
> Your code  and POM looks ok, where did you put your test-classes? Should be
> in src/test/java.
>
> What did you execute? 'mvn test' should compile and run your tests.
>
> hth,
> - martin
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: maven2 with Junit 4 ignores @Test annotations

Posted by Martin Höller <ma...@xss.co.at>.
On Friday 30 May 2008 Martin wrote:
> Looks like you'll need TestDecorator class from junit-4.1
> http://www.jdocs.com/junit/4.1/junit/extensions/TestDecorator.html

No, you don't need this!

Your code  and POM looks ok, where did you put your test-classes? Should be 
in src/test/java.

What did you execute? 'mvn test' should compile and run your tests.

hth,
- martin

Re: maven2 with Junit 4 ignores @Test annotations

Posted by Martin <mg...@hotmail.com>.
Geoffrey-

Looks like you'll need TestDecorator class from junit-4.1
http://www.jdocs.com/junit/4.1/junit/extensions/TestDecorator.html

Martin
----- Original Message ----- 
From: "Geoffrey Wiseman" <ge...@gmail.com>
To: "Maven Users List" <us...@maven.apache.org>
Sent: Thursday, May 29, 2008 8:57 PM
Subject: Re: maven2 with Junit 4 ignores @Test annotations


> On Thu, May 29, 2008 at 6:34 PM, Valluri, Sankar <
> sankarvalluri@fairisaac.com> wrote:
>
>> Am I doing anything wrong here? Or anything else needs to be done?
>
>
> Must be, yeah -- I'm using JUnit 4.X tests with @Test annotations under
> Maven 2, so -- it does work.  I'm not seeing anything specific in our POMs
> to make this happen, so I'm not sure what to suggest.  What error are you
> encountering?
>
> -- 
> Geoffrey Wiseman
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: maven2 with Junit 4 ignores @Test annotations

Posted by Geoffrey Wiseman <ge...@gmail.com>.
On Thu, May 29, 2008 at 6:34 PM, Valluri, Sankar <
sankarvalluri@fairisaac.com> wrote:

> Am I doing anything wrong here? Or anything else needs to be done?


Must be, yeah -- I'm using JUnit 4.X tests with @Test annotations under
Maven 2, so -- it does work.  I'm not seeing anything specific in our POMs
to make this happen, so I'm not sure what to suggest.  What error are you
encountering?

-- 
Geoffrey Wiseman

RE: maven2 with Junit 4 ignores @Test annotations

Posted by "Valluri, Sankar" <sa...@fairisaac.com>.

I am trying to use maven with Junit4 test cases. Eclipse runs these
tests just fine but maven doesn't recognize any of these tests.

Here is the code
import org.junit.Test;
import static org.junit.Assert.*;

public class AdditionTest {
	  private int x = 1;
	  private int y = 1;
	  
	  @Test 
	  public void addition() {
	    int z = x + y;
	    assertEquals(2, z);
	  }
}

POM file
	<dependencies>
  		<dependency>
  			<groupId>org.junit</groupId>
  			<artifactId>junit</artifactId>
  			<version>4.4</version>
  		</dependency>
  	</dependencies>

	<build>
		<plugins>
			<plugin>
	
<groupId>org.apache.maven.plugins</groupId>
	
<artifactId>maven-compiler-plugin</artifactId>
				<configuration>
					<source>1.5</source>
					<target>1.5</target>
				</configuration>
			</plugin>
			<plugin>
	
<groupId>org.apache.maven.plugins</groupId>
	
<artifactId>maven-surefire-plugin</artifactId>
				<version>2.4.3</version>
				<configuration>
					<includes>
	
<include>**/*Test.java</include>
					</includes>
				</configuration>
			</plugin>			
		</plugins>
	</build>


Am I doing anything wrong here? Or anything else needs to be done?

This email and any files transmitted with it are confidential, proprietary
and intended solely for the individual or entity to whom they are addressed.
If you have received this email in error please delete it immediately.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org