Junit - testing instance of a Test class

S

sakcee

is there a way to run an instance/object of this type using Junit. The
reason is that I want to call setVar for setting var. junit can run
class but can it run an object of this class?

something like


import org.junit.*;
import org.junit.After;
import org.junit.Test;
import org.junit.Before;

public class TT {

private String var =null;

public setVar(String s){
var = s;
}

@Before
public void Before(){
}

@Test
public void tt(){
System.out.println("Test1" );
}
@Test
public void tt2(){
System.out.println("Test2" );
}
@Test
public void tt3(){
System.out.println("Test3" );
}


@After
public void After() throws Exception {
System.out.println("after");

}



}
 
C

Chris

is there a way to run an instance/object of this type using Junit. The
reason is that I want to call setVar for setting var. junit can run
class but can it run an object of this class?

Yes, it's possible. Look at the javadoc for TestSuite:

TestSuite suite= new TestSuite();
suite.addTest(new MathTest("testAdd"));
 

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