Junit - testing instance of a Test class

Discussion in 'Java' started by sakcee@gmail.com, May 9, 2007.

  1. Guest

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

    }



    }
     
    , May 9, 2007
    #1
    1. Advertisements

  2. Chris Guest

    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"));
     
    Chris, May 9, 2007
    #2
    1. Advertisements

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Roger
    Replies:
    0
    Views:
    553
    Roger
    Sep 1, 2004
  2. Rhino
    Replies:
    4
    Views:
    6,727
    Roedy Green
    Jan 13, 2006
  3. Sridhar R
    Replies:
    14
    Views:
    1,770
    =?iso-8859-1?Q?Fran=E7ois?= Pinard
    Feb 10, 2004
  4. Edvard Majakari
    Replies:
    4
    Views:
    897
    Edvard Majakari
    Feb 25, 2005
  5. arotem
    Replies:
    4
    Views:
    9,999
    arotem
    Oct 17, 2005
  6. andrewzzz
    Replies:
    2
    Views:
    419
    Mark Jeffcoat
    Feb 27, 2007
  7. Jarrick Chagma

    Eclipse JUnit test class issues

    Jarrick Chagma, Sep 16, 2009, in forum: Java
    Replies:
    1
    Views:
    530
    Markus Eberle
    Sep 20, 2009
  8. Martin P. Hellwig
    Replies:
    1
    Views:
    506
    Martin P. Hellwig
    Mar 26, 2010
Loading...