Home | History | Annotate | Download | only in configuration
      1 package test.configuration;
      2 
      3 import org.testng.Assert;
      4 import org.testng.TestNG;
      5 import org.testng.annotations.BeforeMethod;
      6 import org.testng.annotations.Test;
      7 
      8 import java.util.Arrays;
      9 import java.util.List;
     10 
     11 public class GroupsTest {
     12 
     13   private TestNG m_testNg;
     14 
     15   @BeforeMethod
     16   public void setUp() {
     17     m_testNg = new TestNG();
     18     m_testNg.setVerbose(0);
     19   }
     20 
     21   @Test
     22   public void verifyDataProviderAfterGroups() {
     23     runTest(ConfigurationGroupDataProviderSampleTest.class,
     24         ConfigurationGroupDataProviderSampleTest.m_list,
     25         Arrays.asList(new Integer[] {
     26             1, 2, 2, 2, 3
     27       }));
     28   }
     29 
     30   @Test
     31   public void verifyParametersAfterGroups() {
     32     runTest(ConfigurationGroupInvocationCountSampleTest.class,
     33         ConfigurationGroupInvocationCountSampleTest.m_list,
     34         Arrays.asList(new Integer[] {
     35             1, 2, 2, 2, 3
     36       }));
     37   }
     38 
     39   @Test
     40   public void verifyBothAfterGroups() {
     41     runTest(ConfigurationGroupBothSampleTest.class,
     42         ConfigurationGroupBothSampleTest.m_list,
     43         Arrays.asList(new Integer[] {
     44           1, 2, 2, 2, 2, 2, 2, 3
     45       }));
     46   }
     47 
     48   private void runTest(Class cls, List<Integer> list, List<Integer> expected) {
     49       m_testNg.setTestClasses(new Class[] {
     50           cls
     51       });
     52       m_testNg.run();
     53       Assert.assertEquals(list, expected);
     54   }
     55 }
     56