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

时间:2013-09-08 04:16:11

标签: java junit testng

我正在试验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文件,因为它们看起来彼此不同步。

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

1 个答案:

答案 0 :(得分: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>

测试侦听器正在捕获所有故障,并跳过了步骤/测试。