2014-02-15 253 views
0

我已經設置了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\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 [email protected]: 12 ms 
[TestNG] Time taken by [FailedReporter passed=0 failed=0 skipped=0]: 1 ms 
[TestNG] Time taken by [email protected]: 3 ms 
Creating C:\Users\myName\workspace\Test\test-output\index.html 
[TestNG] Time taken by [email protected]: 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 [email protected]: 27 ms 
[TestNG] Time taken by [email protected]: 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 
+0

你有任何'@ Test'的方法呢?你是否正在導入testng的測試(而不是junit的)? – assylias

+0

您的方法在「測試」組中嗎? – assylias

+0

我在「測試」組中使用了2個@Test方法。當我在eclipse中使用這個xml時,它一切正常,但是形成如上所示的命令行 – Jazz405

回答

0

您需要添加類或包從該組將被拾起。只是組標記將不起作用。

添加從TestNG的documentation一個例子(可以指定,以及根據需要一個包):

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

但是爲什麼xml在Eclipse中工作,而不是從命令行? – Jazz405

+0

你如何在eclipse中觸發你的情況? –

+0

我正在使用testNG插件,你只需要進入項目>運行配置 – Jazz405