【问题标题】:TestNG is not running testsTestNG 没有运行测试
【发布时间】:2014-02-15 00:34:59
【问题描述】:

我已经设置了 TestNG 并正在尝试运行它,但它没有运行我的任何课程。这是输出:

[SuiteRunner] Created 1 TestRunners
[TestRunner] Running test GRP-test on 0  classes,  included groups:[test ] exclu
ded groups:[]
===== Invoked methods
=====
Creating C:\Users\myName\workspace\Test\test-output\Test by groups\GRP-test.ht
ml
Creating C:\Users\myName\workspace\Test\test-output\Test by groups\GRP-test.xm
l

===============================================
    GRP-test
    Tests run: 0, Failures: 0, Skips: 0
===============================================


===============================================
Test by groups
Total tests run: 0, Failures: 0, Skips: 0
===============================================

Creating C:\Users\myName\workspace\Test\test-output\testng-results.xml
[TestNG] Time taken by org.testng.reporters.XMLReporter@4e27c652: 12 ms
[TestNG] Time taken by [FailedReporter passed=0 failed=0 skipped=0]: 1 ms
[TestNG] Time taken by org.testng.reporters.EmailableReporter@201075c5: 3 ms
Creating C:\Users\myName\workspace\Test\test-output\index.html
[TestNG] Time taken by org.testng.reporters.jq.Main@bb2d83d: 29 ms
Creating C:\Users\myName\workspace\Test\test-output\old\Test by groups\toc.htm
l
Creating C:\Users\myName\workspace\Test\test-output\old\Test by groups\GRP-tes
t.properties
Creating C:\Users\myName\workspace\Test\test-output\old\Test by groups\index.h
tml
Creating C:\Users\myName\workspace\Test\test-output\old\Test by groups\main.ht
ml
Creating C:\Users\myName\workspace\Test\test-output\old\Test by groups\groups.
html
Creating C:\Users\myName\workspace\Test\test-output\old\Test by groups\methods
.html
Creating C:\Users\myName\workspace\Test\test-output\old\Test by groups\methods
.html
Creating C:\Users\myName\workspace\Test\test-output\old\Test by groups\methods
-alphabetical.html
Creating C:\Users\myName\workspace\Test\test-output\old\Test by groups\methods
-alphabetical.html
Creating C:\Users\myName\workspace\Test\test-output\old\Test by groups\classes
.html
Creating C:\Users\myName\workspace\Test\test-output\old\Test by groups\reporte
r-output.html
Creating C:\Users\myName\workspace\Test\test-output\old\Test by groups\methods
-not-run.html
Creating C:\Users\myName\workspace\Test\test-output\old\Test by groups\testng.
xml.html
Creating C:\Users\myName\workspace\Test\test-output\old\index.html
[TestNG] Time taken by org.testng.reporters.SuiteHTMLReporter@3c8fa832: 27 ms
[TestNG] Time taken by org.testng.reporters.JUnitReportReporter@4045acb5: 0 ms

这是我的 xml:

   <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
    <suite name="Test by groups">
      <test verbose="10" name="GRP-test">
       <groups>
        <run>
          <include name="test"/>
        </run>
       </groups>

      </test> <!-- GRP-test -->
    </suite> <!-- Test by groups -->

我要做的是让我的硒测试运行。我已经让它们在 Eclipse 中成功运行,但我正在转向命令行以使其更容易一些(讽刺的是,对吧?)。

这是我的命令行:

C:\Users\myName\workspace\Test>java -cp C:\Users\myName\Documents\Eclipse\li
bs\testng-6.8.jar;C:\Users\myName\workspace\Test\bin\test\* org.testng.TestNG
testng.xml

【问题讨论】:

  • 你有@Test的方法吗?您是在导入 testng 的测试(而不是 junit 的)吗?
  • 你的方法在“测试”组吗?
  • 我在“测试”组中使用了 2 个 @Test 方法。当我在 Eclipse 中使用该 xml 时,一切正常,但是在命令行中它会像上面那样操作

标签: java testing testng


【解决方案1】:

您需要添加要从中提取组的类或包。只是组标签不起作用。

添加来自testng documentation的示例(您也可以根据需要指定一个包):

<test name="Test1">
  <groups>
    <run>
      <include name="functest"/>
    </run>
  </groups>
  <classes>
    <class name="example1.Test1"/>
  </classes>
</test>

【讨论】:

  • 但是为什么那个 xml 在 Eclipse 中可以工作而不是从命令行呢?
  • 你如何在 Eclipse 中触发你的案例?
  • 我用的是testNG插件,你直接去Project>Run Configuration
  • 好的,你指定什么作为你的配置?如果您想仅基于您的 XML 模拟运行,则只需右键单击您的 XML 并选择作为 Testng 套件运行。如果运行,那么我可以进一步检查。
猜你喜欢
  • 2014-02-04
  • 2021-04-18
  • 2018-03-27
  • 1970-01-01
  • 1970-01-01
  • 2023-03-10
  • 1970-01-01
  • 2017-04-23
  • 2017-01-09
相关资源
最近更新 更多