配置失败导致TestNG中的测试跳过,而XML中没有信息

问题描述 投票:7回答:1

我正在试验TestNG,并且它正在Eclipse中运行。我创建了一个测试套件,并尝试从命令行运行它。

构建失败,并显示错误信息

构建期间的最终输出说:

  [testng] ===============================================
   [testng] Suite
   [testng] Total tests run: 1, Failures: 0, Skips: 1
   [testng] Configuration Failures: 1, Skips: 2
   [testng] ===============================================
   [testng] 
   [testng] The tests failed.

testng-results.xml和index.html没有报告任何故障。

testng-failed.xml就像这样:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Failed suite [Default suite]">
  <test name="Default test(failed)">
    <classes>
      <class name="ABC.test.integration.PersistUrlTests">
        <methods>
          <include name="springTestContextAfterTestClass"/>
          <include name="springTestContextBeforeTestClass"/>
          <include name="springTestContextPrepareTestInstance"/>
          <include name="springTestContextAfterTestMethod"/>
          <include name="checkTest"/>
        </methods>
      </class> <!-- ABC.test.integration.PersistUrlTests -->
    </classes>
  </test> <!-- Default test(failed) -->
</suite> <!-- Failed suite [Default suite] -->

测试如下:

@Test
@ContextConfiguration(locations = { "file:spring-configuration/mydb-integration-testing.xml" })
public class PersistUrlTests extends AbstractTestNGSpringContextTests {

        @Autowired
        protected MobiusDatabaseServiceClient mobiusDatabaseServiceClient;

        @Autowired
        UrlDAO urlDAO;

        @Autowired
        ScraperUrlDAO scraperUrlDAO;

        @BeforeClass
        public void init() throws Exception {

        }


        @Test
        public void checkTest() {
            GetActiveCategoriesResponse response = mobiusDatabaseServiceClient.newGetActiveCategoriesCall().call();
            System.out.println(response.getCategoryList());
            Assert.assertTrue(true);
        }
}

套房外观如下:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Suite" parallel="none">
  <test name="Test">
    <classes>
      <class name="ABC.mydatabase.test.integration.PersistUrlTests"/>
    </classes>
  </test> <!-- Test -->
</suite> <!-- Suite -->

但是,另一方面,该文件的最后更新时间是过去的时间。我不确定它是否正在更新。

我不确定如何调试testNG生成的XML文件,因为它们似乎彼此不同步。

应该准确查看哪个文件?为什么他们不支持失败的“配置”?

java junit testng
1个回答
0
投票

您是否为测试分配了测试侦听器?

    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Group D - Using variables" parallel="false" preserve-order="true">
  <listeners>    
    <listener class-name="com.reportng.JUnitXMLReporter"/>
  </listeners>
© www.soinside.com 2019 - 2024. All rights reserved.