-
Jan 17th, 2012, 11:40 AM
#1
SpringJUnit4ClassRunner not present
Hi,
I'm trying to run JUnit Test from maven using SpringJUnit4ClassRunner but I'm getting error when running test with maven in Eclipse. I'm using Spring 3.1 & Junit 4 from Eclipse
Error is:
Tests in error:
mtw.devstuff.spring.SetterMessageTest: Type org.springframework.test.context.junit4.SpringJUni t4ClassRunner not present
I do have org.springframework.test-3.1.0.RELEASE.jar in my project classpath
Code is pretty simple:
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration
public class SetterMessageTest {
final Log logger = LogFactory.getLog(SetterMessageTest.class);
@Autowired
private SetterMessage message = null;
@Test
public void testMessage()
{
Assert.assertNotNull("Constructor message instance is null.", message);
String msg = message.getMessage();
Assert.assertNotNull("Message is null.", msg);
String expectedMessage = "Spring is fun.";
Assert.assertEquals("Message should be '" + expectedMessage + "'.", expectedMessage, msg);
logger.info(msg);
}
Any ideas why? Is it my maven config? Before the error last maven output is:
[INFO] --- maven-surefire-plugin:2.7.2:test (default-test) @ SpringByExample02 ---
[INFO] Surefire report directory: C:\mystuff\DevelopmentStuff\Spring\SpringByExample 02\SpringByExample02\target\surefire-reports
Mike
-
Jan 17th, 2012, 01:50 PM
#2
RE: SpringJUnit4ClassRunner not present
If I run the test class as JUnit test, it runs successfully, but when I try to run from Maven I get the error SpringJUnit4ClassRunner not present. So, I suspect it is related to Maven and what it using as far as jar's. Any suggestions on how to debug why Maven is not seeing ?
Mike
-
Jan 17th, 2012, 02:08 PM
#3
RE: SpringJUnit4ClassRunner not present
For anyone interested, I figured out my error. I was missing dependency in my pom file, so it was a maven thing.
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>3.1.0.RELEASE</version>
<scope>test</scope>
</dependency>
Mike
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules