I'm running Eclipse SDK 3.3.0 and
Maven 2.0.7.
I have created a new empty project. I use maven to download junit4.0.jar
into the Maven2 Dependences.
I'm trying to follow the demo at
http://m2eclipse.codehaus.org/Maven_2.0_Plugin_for_Eclipse.html except use junit4 and it is not working!
All I want to do is create a simple
Unit test in eclipse and execute it maven. What am I doing wrong?
See below for more details.
Thanks,
Siegfried
I right click on the project -> new ->
Junit Test and it creates a package
for me that is in the top level directory for that project? Should it not be
under main/test?
Well here is my test:
package m2Test;
import static org.junit.Assert.*;
import org.junit.Assert;
public class simple2 {
@Test
public void simple(){
Assert.assertNotNull(new
String());
}
}
Well I right click on the project again and select Run As -> JUnit Test and
it says 'No tests found with test runner 'JUnit 4'. Why not?
So then I move the test into the main/test and I still get the same result.
So then I try a JUnit 3 test and that does not work either (scroll way down
to see my JUnit3 test). So then I try to get maven to execute the tests (I
right click on pom.xml, select run as -> maven 2 buld ) and it cannot find
any tests to run either. Maven does run a C++ project in the same workspace!
Is this an eclipse problem or a maven plugin problem? I think it is (at
least in part) an eclipse issue since it cannot find my tests with just the
'Run As -> JUnit Tests'.
Thanks,
Siegfried
[INFO] ----------------------------------------------------------------------------
[INFO] Building Unnamed - demo:Maven_Hibernate_Spring_Demo:jar:0.0.1
[INFO] task-segment: [test]
[INFO] ----------------------------------------------------------------------------
[INFO] resources:resources
[INFO] Using default encoding to copy filtered resources.
[INFO] compiler:compile
[INFO] No sources to compile
[INFO] resources:testResources
[INFO] Using default encoding to copy filtered resources.
[INFO] compiler:testCompile
[INFO] No sources to compile
[INFO] surefire:test
[INFO] No tests to run.
[INFO] ----------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ----------------------------------------------------------------------------
[INFO] Total time: 0 second
[INFO] Finished at: Mon Sep 17 23:01:40 MDT 2007
[INFO] Memory 2M/6M
[INFO] ----------------------------------------------------------------------------
// JUnit 3 test:
/**
*
*/
package m2Test;
import junit.framework.TestCase;
/**
* @author Siegfried Heintze
*
*/
public class SimpleJUnit3 extends TestCase {
/**
* @param name
*/
public SimpleJUnit3(String name) {
super(name);
}
/* (non-Javadoc)
* @see junit.framework.TestCase#setUp()
*/
protected void setUp() throws Exception {
super.setUp();
}
/* (non-Javadoc)
* @see junit.framework.TestCase#tearDown()
*/
protected void tearDown() throws Exception {
super.tearDown();
}
public testSimple(){
SimpleJUnit3 s = new SimpleJUnit3("demo");
assertNotNull(s);
}
}