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. Advertising

  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. Advertising

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. Sridhar R
    Replies:
    14
    Views:
    1,379
    =?iso-8859-1?Q?Fran=E7ois?= Pinard
    Feb 10, 2004
  2. Edvard Majakari
    Replies:
    4
    Views:
    671
    Edvard Majakari
    Feb 25, 2005
  3. andrewzzz
    Replies:
    2
    Views:
    306
    Mark Jeffcoat
    Feb 27, 2007
  4. Jarrick Chagma

    Eclipse JUnit test class issues

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

Share This Page