Announcement Announcement Module
Collapse
No announcement yet.
Tests work in Eclipse, but not Maven (yes, another one) Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    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.

    Comment


    • #3
      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, 08:39 AM. Reason: Adding changed config

      Comment

      Working...
      X