2017-01-02 35 views
0

在Eclipse Neon.2中運行的TestNG測試中,我需要測試的代碼來訪問我在運行測試的配置。這確實奏效,但問題是TestNG本身使用這個參數,顯然認爲它代表了一些文件;所以測試運行時,出現在Eclipse控制檯的第一件事就是:TestNG使用的程序參數是用於測試的代碼,而不是用於TestNG

java.io.IOException: The filename, directory name, or volume label syntax is incorrect 
    at java.io.WinNTFileSystem.canonicalize0(Native Method) 
    at java.io.WinNTFileSystem.canonicalize(WinNTFileSystem.java:428) 
    at java.io.File.getCanonicalPath(File.java:618) 
    at org.testng.xml.Parser.parse(Parser.java:151) 
    at org.testng.TestNG.initializeSuitesAndJarFile(TestNG.java:311) 
    at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:88) 
    at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204) 
    at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175) 

我設置這樣的說法在運行配置的測試,在「參數」選項卡,在「程序參數」。論點是homepath=C:/MyFolder,這是唯一的。 「VM參數」中沒有設置參數。

有沒有辦法告訴TestNG忽略某個程序參數?

TestNG插件是ver。 6.8.6.20141201_2240,Windows 8.1。

回答

1

如果您爲TestNG創建「運行配置」,則「程序參數」用於TestNG,而不是您的應用程序。 所以如果你的應用需要一些背景相似的命令行參數,您可以在「VM參數」與-Dfoo=bar通過,或有環境變量,並在您的應用程序通過調用System.getProperty()讓他們,或System.getenv()