Loading ...
Sorry, an error occurred while loading the content.
 

Suites in Junit4?

Expand Messages
  • otterblob
    Hello, I have just started using Junit and am very pleased with it. But one problem is how to organise groups of test classes into suites. In v3.8 it seemed
    Message 1 of 3 , Apr 28, 2006
      Hello,
      I have just started using Junit and am very pleased with it. But
      one problem is how to organise groups of test classes into suites. In
      v3.8 it seemed very easy - just make your own class with a static suite()
      method and then add your required classes.
      But how do you do this in version 4? The only documentation I've found
      ( in the javadocs)
      suggests addin @RunWith annotations to your suite class but I don't
      understand what to do, or how you specify a list of test classes .
      Many thanks for any advice!
    • Kent Beck
      Dear Otterblob, If your IDE won t find the tests for you, you can create a JUnit 4 test suite by annotating a class with RunWith(Suite.class) and
      Message 2 of 3 , May 3, 2006
        Dear Otterblob,

        If your IDE won't find the tests for you, you can create a JUnit 4 test
        suite by annotating a class with RunWith(Suite.class) and
        SuiteClasses(...classes...). You can see an example of this in
        org.junit.tests.AllTests:

        @RunWith(Suite.class)
        @SuiteClasses({
        ListenerTest.class,
        ...
        JUnitCoreTest.class
        })
        public class AllTests {
        }

        Sincerely yours,

        Kent Beck
        Three Rivers Institute

        > -----Original Message-----
        > From: junit@yahoogroups.com [mailto:junit@yahoogroups.com] On
        > Behalf Of otterblob
        > Sent: Friday, April 28, 2006 6:36 AM
        > To: junit@yahoogroups.com
        > Subject: [junit] Suites in Junit4?
        >
        > Hello,
        > I have just started using Junit and am very pleased with it. But
        > one problem is how to organise groups of test classes into suites. In
        > v3.8 it seemed very easy - just make your own class with a
        > static suite()
        > method and then add your required classes.
        > But how do you do this in version 4? The only documentation I've found
        > ( in the javadocs)
        > suggests addin @RunWith annotations to your suite class but I don't
        > understand what to do, or how you specify a list of test classes .
        > Many thanks for any advice!
      • srikant.lakhanpal
        ... i m providing u sample format to solve ur purpose ======================================== test classes ======================================== class
        Message 3 of 3 , May 16, 2006
          --- In junit@yahoogroups.com, "otterblob" <otterblob@...> wrote:
          >
          > Hello otterblob,
          i m providing u sample format to solve ur purpose
          ========================================
          test classes
          ========================================
          class SampleTestA
          {
          @Test
          public void method1()
          {
          }

          @Test
          public void method2()
          {
          }
          }

          class SampleTestB
          {
          @Test
          public void method1()
          {
          }

          @Test
          public void method2()
          {
          }
          }

          ========================================
          Suite class
          ========================================

          @RunWith(Suite.class)
          @SuiteClasses({SampleTestA.class,SampleTestB.class})
          public class SampleSuite
          {
          public static Test suite ()
          {
          return new JUnit4TestAdapter(SampleSuite.class);
          }
          }
        Your message has been successfully submitted and would be delivered to recipients shortly.