junit test in eclipse  
Author Message
Sean Kim





PostPosted: 2008-2-11 13:23:00 Top

java-programmer, junit test in eclipse
code from some tutorial
---------
import junit.framework.TestCase;
public class SampleTest extends TestCase {
...
}
---------

code from another tutorial
---------
import org.junit.*;
import static org.junit.Assert.*;

public class SampleTest {
...
}
---------

Second one is working well. I think second one is simpler, so I like it.
But I can't use them with TestSuite.
"
The method addTest(Test) in the type TestSuite is not applicable for the
arguments
(Class<ArmorTypeWrapperTest>)
"
---------
import junit.framework.Test;
import junit.framework.TestSuite;

public class AllTests {

public static Test suite() {
TestSuite suite = new TestSuite("Test for vanguard.wardrobe");
//$JUnit-BEGIN$
suite.addTest(ArmorTypeTest.class);
suite.addTest(ArmorTypeWrapperTest.class);
//$JUnit-END$
return suite;
}
}
---------

Thank you

Sean
 
voorth





PostPosted: 2008-2-11 20:48:00 Top

java-programmer >> junit test in eclipse On Feb 11, 6:23 am, Sean Kim <email***@***.com> wrote:
> code from some tutorial
> ---------
> import junit.framework.TestCase;
> public class SampleTest extends TestCase {
> ...}
>
> ---------
>
> code from another tutorial
> ---------
> import org.junit.*;
> import static org.junit.Assert.*;
>
> public class SampleTest {
> ...}
>
> ---------
>
> Second one is working well. I think second one is simpler, so I like it.

A few observations:
- What version of Eclipse do you use? AFAIK, JUnit 4 is support from
version 3.2 on.
- Make sure you have JUnit 4 on your build path.
- There is no need for an AllTests suite in Eclipse. "Run as.. > JUnit
Test" on a package, source folder, or even your project will run all
unit tests in that component.