Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/list/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
将测试用例作为TestNG测试运行时的TestNgeException_Testng - Fatal编程技术网

将测试用例作为TestNG测试运行时的TestNgeException

将测试用例作为TestNG测试运行时的TestNgeException,testng,Testng,我正在尝试运行一个带有登录方法的TestNG测试。我在@Test处传递参数,在testng.xml中也传递参数。如果我将登录测试作为Testsuite运行,则登录测试将通过,但如果我将测试用例作为testng测试运行,则登录测试将失败,并给出以下错误: org.testng.TestNGException: @Test on method loginTest需要参数“Username” 但未标记为@Optional或在C:\\AppData\Local\Temp\testng eclipse--

我正在尝试运行一个带有登录方法的TestNG测试。我在@Test处传递参数,在testng.xml中也传递参数。如果我将登录测试作为Testsuite运行,则登录测试将通过,但如果我将测试用例作为testng测试运行,则登录测试将失败,并给出以下错误: org.testng.TestNGException: @Test on method loginTest需要参数“Username” 但未标记为@Optional或在C:\\AppData\Local\Temp\testng eclipse--146657283\testng-customsuite.xml中定义


我的testng.xml与当前项目位于同一工作区。

您可能在套件xml中指定用户名作为参数。当您作为套件运行时,将使用特定的xml。但是,当您选择一个测试并运行它时,testng会创建一个定制的testng文件(没有最小值-没有参数,没有侦听器-您可以在您提到的路径上查看该文件)

如果您使用的是标准xml,则需要在eclipse中将xml指定为模板xml。转到project properties->testng->将xml设置为模板xml