运行testng xml时出现空指针异常

时间:2018-11-19 08:11:31

标签: testng

这是testng xml的问题,我正在分配组,这导致出现此问题。当我运行testng.xml文件时,它给出错误null指针异常,如下所示。但是,当我从xml文件中删除组时,它工作正常。无法找出问题出在哪里。

感谢您的帮助。

错误-

java.lang.NullPointerException
    at com.kaleyra.smsApi.qa.framework.collection.SendSMS.SendSMSQuick(SendSMS.java:24)
    at testApi_Test_Scripts.Runner.SendSMS(Runner.java:65)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at 

Testng.xml文件-

<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="ApiAutomationTestSuite">
    <listeners>
        <listener class-name="org.uncommons.reportng.HTMLReporter" />
        <listener class-name="org.uncommons.reportng.JUnitXMLReporter"/>
    </listeners>
    <test name="SMS_API_AUTOMATION_TEST" preserve-order="true">
        <groups>
        <run>
            <include name="Smoke" />
        </run>
        </groups>
        <classes>
            <class name="testApi_Test_Scripts.Runner"/>
        </classes>
    </test>
</suite>

Runner文件

import java.io.File;

public class Runner {

    private ExtentReports extent;
    private ExtentTest log;
    SendSMS Msg = new SendSMS();

    @BeforeTest
    public void starttest() {
        System.setErr(System.out); // continue.. and remove the warnings
        extent = new ExtentReports(System.getProperty("user.dir") + "/test-output/" + Outputfilename + ".html", true);
        extent.addSystemInfo("Host Name", "XXXX")
        extent.loadConfig(new File(System.getProperty("user.dir") + "/extent-config.xml"));
    }

    @Test(priority = 1,groups = { "Smoke" })
    public void SendSMS() throws InterruptedException {
        Msg.SendSMSQuick(extent);
    }
}

0 个答案:

没有答案