Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Junit - testing instance of a Test class

Reply
Thread Tools

Junit - testing instance of a Test class

 
 
sakcee@gmail.com
Guest
Posts: n/a
 
      05-09-2007

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");

}



}

 
Reply With Quote
 
 
 
 
Chris
Guest
Posts: n/a
 
      05-09-2007
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> 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"));
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Testing class with no methods with junit andrewzzz Java 2 02-27-2007 01:32 AM
TypeError: unbound method PrintInput() must be called with test instance as first argument (got test instance instead) arotem Python 4 10-17-2005 07:52 AM
Unit testing - one test class/method, or test class/class Edvard Majakari Python 4 02-25-2005 07:31 PM
Cannot refer to an instance member of a class from within a shared method or shared member initializer without an explicit instance of the class. DJ Dev ASP .Net 3 02-08-2004 04:19 PM
test test test test test test test Computer Support 2 07-02-2003 06:02 PM



Advertisments