When I try to run JUnit-Test from Eclipse, I get a "ClassNotFoundException". When you run "mvn test" from the console, everything works fine. In addition, there is no problem with Eclipse.
My project structure is as follows:
- parent project (pom-packaging)
- Web project (military packaging - my JUnit test is here)
- Flex Project
- Configuration project
edit: How can a class not be found? This is a simple HelloWorld application without special libraries.
Here is my JUnit run-configuration: alt text http://www.walkner.biz/_temp/runconfig.png
Testclass (but as I said, it does not work with simple HelloWorld either ...):
import org.junit.After; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; import biz.prognoserechnung.domain.User; import biz.prognoserechnung.domain.UserRepository; import biz.prognoserechnung.domain.hibernate.UserHibernateDao; public class UserDaoTest { private ApplicationContext ctx = null; private User record = null; private UserRepository dao = null; @Before public void setUp() throws Exception { String[] paths = { "WEB-INF/applicationContext.xml" }; ctx = new ClassPathXmlApplicationContext(paths); dao = (UserHibernateDao) ctx.getBean("userRepository"); } @After public void tearDown() throws Exception { dao = null; } @Test public final void testIsUser() throws Exception { Assert.assertTrue(dao.isUser("John", "Doe")); } @Test public final void testIsNoUser() throws Exception { Assert.assertFalse(dao.isUser("not", "existing")); Assert.assertFalse(dao.isUser(null, null)); Assert.assertFalse(dao.isUser("", "")); } }
java eclipse exception maven-2
swalkner Jun 27 '09 at 15:01 2009-06-27 15:01
source share