Java 一个testNG测试用例在一组测试用例中失败,无法确定问题是什么?
我刚开始学习SeleniumWebDriver和testNG。我试图通过下面的一组测试用例学习一些testNG注释,但是有一个测试用例总是失败,我无法找出错误是什么 此外,我尝试搜索现有问题,但找不到与我的问题匹配的问题。因此,我将在这里解释我试图实现的目标:Java 一个testNG测试用例在一组测试用例中失败,无法确定问题是什么?,java,eclipse,unit-testing,testng,Java,Eclipse,Unit Testing,Testng,我刚开始学习SeleniumWebDriver和testNG。我试图通过下面的一组测试用例学习一些testNG注释,但是有一个测试用例总是失败,我无法找出错误是什么 此外,我尝试搜索现有问题,但找不到与我的问题匹配的问题。因此,我将在这里解释我试图实现的目标: 我创建了三个类,其中包含testNGannotations测试用例。类名称为:testing1和testing2 然后,我创建了一个testngxml文件,以便这些测试用例可以作为一个套件执行 我还创建了一个属性文件(path.prope
testNG
annotations测试用例。类名称为:testing1
和testing2
path.properties
),其中存储了一些我想在testing
类的test2
中使用的XPathtesting
类的test2
总是失败,但是eclipse没有显示任何语法错误,我无法理解问题是什么这里的
testing
类的test2
失败,它使用了属性文件。我认为没有加载属性是因为这一行:
FileInputStream fis= new FileInputStream (System.getProperty("C:\\Users\\SumitKumar.Dubey\\workspace\\My_testNG\\src\\paths.properties"));
请从此行中删除System.getProperty(),并在文件对象中指定路径,如下所示
FileInputStream fis= new FileInputStream (new File("C:\\Users\\SumitKumar.Dubey\\workspace\\My_testNG\\src\\paths.properties"));
谢谢你,贾加纳坦。我试过了,成功了。如果可能的话,你能再详细阐述一下这个概念吗?实际上,我阅读了一些教程,并基于此尝试了这种方法。如果将属性文件的路径存储在系统属性中,比如testng.properties.file.path,则可以使用
System.getProperty(“testng.properties.file.path”)代码>在您的情况下,我相信您没有系统属性,只有属性文件的路径。所以,我们只是直接从文件路径加载属性。是的,这是正确的,它只是属性文件的路径。非常感谢您的及时回复:)可能重复的
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Suite">
<test name="Test1">
<classes>
<class name="testingNG1"/>
</classes>
</test>
<test name="Test2">
<classes>
<class name="testingNG2"/>
</classes>
</test>
<test name="Test3">
<classes>
<class name="testingNG"/>
</classes>
</test>
</suite> <!-- Suite -->
#Dalal Street Login
DLJ_Login_Button=//a[@id='dnn_dnnLogin_enhancedLoginLink']
DLJ_Login_Username=//input[@id='dnn_ctr5070_Login_Login_DNN_txtUsername']
DLJ_Login_Pwd=//input[@id='dnn_ctr5070_Login_Login_DNN_txtPassword']
DLJ_click_login=//input[@id='dnn_ctr5070_Login_Login_DNN_cmdLogin']
FileInputStream fis= new FileInputStream (System.getProperty("C:\\Users\\SumitKumar.Dubey\\workspace\\My_testNG\\src\\paths.properties"));
FileInputStream fis= new FileInputStream (new File("C:\\Users\\SumitKumar.Dubey\\workspace\\My_testNG\\src\\paths.properties"));