junit test in eclipse

S

Sean Kim

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;
}
}
 
V

voorth

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 {
...}

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top