1
XmlSuite suite = new XmlSuite();
suite.setName("RegSuite");
XmlTest test = new XmlTest(suite);
test.setName("MyTest");
List<XmlClass> classes = new ArrayList<XmlClass>();
classes.add(new XmlClass("tests.test1"));
test.setXmlClasses(classes) ;
List<XmlSuite> suites = new ArrayList<XmlSuite>();
suites.add(suite);
TestNG tng = new TestNG();
tng.setXmlSuites(suites);
tng.run();

@test1
public void test1(){

    try{
        ModifiableSDKConfiguration config = new ModifiableSDKConfiguration();
        config.setServerAddress(new URI("ws://myServerAddress:5095"));
        SDK.init(config);
        Reporter.init();

       Browser OBrowser = BrowserFactory.Launch(BrowserType.InternetExplorer);
      Console.WriteLine("Navigating to Google.com");
      OBrowser.Navigate("Google.com");
      OBrowser.Sync();
      Reporter.ReportEvent("Browser Sync", "Browser sync completed", HP.LFT.Report.Status.Passed);
      OBrowser.Close();

      //test code

      Console.WriteLine("Generatig reports and closing SDK");

      //Generate the report and cleanup the SDK usage.
      Reporter.generateReport();
      SDK.cleanup();
    } catch(Exception e){
    }
}

在上述情况下,我的报告已生成并且一切正常,但唯一的问题是 JVM 从未终止并永远等待。请在这里帮助我。我还尝试添加@beforeclass 和@afterclass 方法来拆除测试和测试套件但没有运气,如果尝试从Testng.XML 文件运行它工作正常但我想生成xml 运行时,因为这是我的框架要求

4

0 回答 0