class  Vehicle
{
        @BeforeGroups("car")
        function bg()
        {

        }
          @AfterGroups("car")
        function bg()
        {

        }
       @Test(groups={car})
       public void car1()
       {

       }
      @Test(groups={car})
       public void car2()
       {

       }
      @Test(groups={scooter})
       public void scooter1()
       {

       }
      @Test(groups={scooter})
       public void scooter2()
       {

       }
      @Test(groups{scooter,car})
      public void car_scooter()
     {

     }


}


create testng.xml file and execute them

<suite name="Suite">

    <test name="Practice Grouping">
      <groups>
       <run>
          <include name="Car" />
       </run>
      </groups>
      <classes>
        <class name="packagename.Classname" />
      </classes>
    </test>

</suite>


To run multiple group

<suite name="Suite">

   <test name="Practice Grouping">

      <groups>

         <define name="All">

    <include name="Car"/>

    <include name="Scooter"/>

</define>

<run>

    <include name="All"/>

</run>

    </groups>

<classes>

      <class name="package.Grouping" />

</classes>

   </test>

</suite>

Post a Comment

If you have any doubt in programming or join online classes then you can contact us by comment .

Previous Post Next Post