Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / May 2007

Tip: Looking for answers? Try searching our database.

Junit - testing instance of a Test class

Thread view: 
sakcee@gmail.com - 09 May 2007 21:08 GMT
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");

    }

}
Chris - 09 May 2007 23:16 GMT
> 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"));


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.