Results 1 to 3 of 3

Thread: Tests work in Eclipse, but not Maven (yes, another one)

Hybrid View

  1. #1
    Join Date
    Sep 2007
    Posts
    6

    Default Tests work in Eclipse, but not Maven (yes, another one)

    I've tried searching around the web and these forums for a solution to my problem, but nothing is working out.

    I have a seemingly not uncommon problem - my tests run successfully in Eclipse using "Run As > JUnit Test", but "maven clean test" produces failures and errors.

    First, some setup info:
    Code:
    Eclipse 3.6.2
    Maven 2.2.1
    Java 1.6.0_24
    in my pom.xml dependencies
    Code:
    		<dependency>
    			<groupId>org.junit</groupId>
    			<artifactId>com.springsource.org.junit</artifactId>
    			<version>4.8.1</version>
    			<scope>test</scope>
    		</dependency>
    and my surefire config (the one that is closest to working, as measured by number of failures and errors)
    Code:
    			<plugin>
    				<artifactId>maven-surefire-plugin</artifactId>
    				<configuration>
    					<junitArtifactName>org.junit:com.springsource.org.junit</junitArtifactName>
    					<testFailureIgnore>false</testFailureIgnore>
    				</configuration>
    			</plugin>
    and test classes are annotated thus:
    Code:
    @RunWith(SpringJUnit4ClassRunner.class)
    //ApplicationContext will be loaded from "classpath:/services/spring/sdk/service/TestServiceAspect-context.xml"
    @ContextConfiguration
    I've been trying for 2 days to figure out what's going on. Anyone have any ideas on what I can try? There's no extra versions of Spring or JUnit when I run "mvn dependency:tree", everything compiles fine, and I see logging output from the SpringJUnit4ClassRunner class, so it's being invoked (I have a log4j.properties in src/test/resources that sends all logging output to target/test.log).

  2. #2
    Join Date
    Jul 2010
    Location
    Venice, Italy
    Posts
    709

    Default

    Just stop using the JUnit bundled with Spring and start using the unbundled version:

    Code:
    <dependency>
    			<groupId>junit</groupId>
    			<artifactId>junit</artifactId>
    			<version>4.8.1</version>
    			<scope>test</scope>
    		</dependency>
    This should solve your problems.

  3. #3
    Join Date
    Sep 2007
    Posts
    6

    Default

    That's what was there when the problem started. I changed to the Spring bundled one in hopes that it would work better. The configurations below have exactly the same problems.

    Code:
    <dependency>
    	<groupId>junit</groupId>
    	<artifactId>junit</artifactId>
    	<version>4.8.1</version>
    	<scope>test</scope>
    </dependency>
    Code:
    <plugin>
    	<artifactId>maven-surefire-plugin</artifactId>
    	<configuration>
    		<testFailureIgnore>false</testFailureIgnore>
    	</configuration>
    </plugin>
    Last edited by duckpuppy; Apr 13th, 2011 at 08:39 AM. Reason: Adding changed config

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •