Java TestNG没有运行测试

Java TestNG没有运行测试,java,testing,testng,Java,Testing,Testng,我已经设置了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\T

我已经设置了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 -->

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

添加testng中的示例(您也可以根据需要指定包):



你有什么
@测试方法吗?您是否正在导入testng的测试(而不是junit的)?您的方法是否在“测试”组中?我在“测试”组中使用了2个@Test方法。当我在eclipse中使用该xml时,它可以正常工作,但在命令行中它可以如上所述。但是为什么在eclipse中该xml可以正常工作,而不是从命令行?在eclipse中如何触发您的案例?我使用的是testNG插件,您只需进入Project>Run ConfigurationOk,然后指定什么作为您的配置?如果您希望仅基于XML模拟运行,那么右键单击XML并选择RunasTestNG套件。如果它运行,那么我可以进一步检查它。
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 name="Test1">
  <groups>
    <run>
      <include name="functest"/>
    </run>
  </groups>
  <classes>
    <class name="example1.Test1"/>
  </classes>
</test>