Navigation

    SOFTWARE-TESTING.COM

    • Register
    • Login
    • Search
    • Jobs
    • Tools
    • Companies
    • Conferences
    • Courses
    1. Home
    2. baileigh
    3. Best
    B
    • Profile
    • Following
    • Followers
    • Topics
    • Posts
    • Best
    • Groups

    Best posts made by baileigh

    • RE: JUnit + Maven. How to do something before and after all tests?

      In general, this solution will be useful to anyone who wants to test consistently and in a given order.

      It creates a suite, where in the annotation we list the classes in the order of execution:

      @RunWith (Suite.class)
      @ Suite.SuiteClasses ({OpenConnection.class,
                       GetServerIdTest.class,
                       ModbusStatusCodesTest.class,
                       ModbusSerialTransactionTest.class,
                       CloseConnection.class})
      public class OrderedTestSuite {}
      

      Add the plugin to pom.xml:

      <plugin>
               <groupId> org.apache.maven.plugins </groupId>
               <artifactId> maven-surefire-plugin </artifactId>
               <configuration>
                   <includes>
                       <include> ** / OrderedTestSuite.class </include>
                   </includes>
               </configuration>
      </plugin>
      
      posted in Automated Testing
      B
      baileigh
    • 1 / 1