Prabu
Prabu

Reputation: 3728

TestNG Groups wise Test Execution not Working from xml file

Please help me to execute an test with group wise using testng xml file

i have an class with inherit a subclass

public class testcase extends Loginclass {

inside this class i have an multiple Test with Groups

@Test(dataProvider = "In_credentials", groups ={"Login_cred"})
@Test(dataProvider = "Invalid_credentials", groups ={"Login_cred"})

so in my XML file i have to include the Group name to execute only the above test my xml file is

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Suite for Login" >
  <test name="Login validation">
  <groups>
  <run>
  <include name ="Login_cred"/>
  </run>
  </groups>
    <classes>
      <class name="pk.webdriver.testcase">
      </class>
      </classes>
  </test> <!-- Test -->
</suite> <!-- Suite -->

During the Execution i got an NUll pointer Exception, please suggest to me how we define the xml file for that above case (we are using Page Object Design Pattern)

thanks prabakar M

Upvotes: 1

Views: 3586

Answers (4)

user11818174
user11818174

Reputation: 1

You can try including beforeClass method also in the group. This might work for your case.

Upvotes: 0

Ran Adler
Ran Adler

Reputation: 3707

it should work but you can try a package also 

<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="ProjectName" verbose="10" parallel="false">
    <test name="Full Regression">
        <groups>
            <run>
                <include name="Login_cred" />
            </run>
        </groups>
        <packages>
            <package name="com.my.test" />
        </packages>     
    </test>
</suite>

@Test(groups = { "Login_cred" }, dataProvider = "testData")

see that the test is public !!!

Upvotes: 0

Archana Singh
Archana Singh

Reputation: 39

As ur class extends another class ,try including another class in xml file as well along with

Upvotes: 0

Test
Test

Reputation: 56

If there are any Before method and After method for this test case , then keep the parameter as "alwaysrun=true". It will work

Upvotes: 4

Related Questions