java 我必须将 testng.xml 放在哪个目录中?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12644035/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-31 09:40:32  来源:igfitidea点击:

In which directory I have to place testng.xml?

javamaventestng

提问by DevCoder

I'm doing one project in which I have to perform automation testing. For this purpose I'm using Testng framework.

我正在做一个项目,我必须在其中执行自动化测试。为此,我使用了 Testng 框架。

I am giving testng.xmlas input file and some method will consume it, however right now my reader method is not able to detect the file.

我提供testng.xml作为输入文件,某些方法会使用它,但是现在我的阅读器方法无法检测到该文件。

In which directory I to place my testng.xmlfile..... and is there any maven specification I have to make in pom.xmlfor detecting that testng.xmlfile is there and they have to read it.

我将testng.xml文件放在哪个目录中..... 是否有任何 Maven 规范我必须pom.xml用来检测该testng.xml文件是否存在并且他们必须阅读它。

回答by Gray

In which directory I to place my testng.xml file.....

在哪个目录中放置我的 testng.xml 文件.....

I suspect that the testng.xmlfile should be put at the top of your classpath. If you are using maven then a good place for it would be src/test/resources/testng.xml. See this example:

我怀疑该testng.xml文件应该放在类路径的顶部。如果您使用的是 maven,那么它的好地方就是src/test/resources/testng.xml. 看这个例子:

How to call testng.xml file from pom.xml in Maven

is there any maven specification I have to make in pom.xml for detecting that testng.xml file is there and they have to read it.

如何在 Maven 中从 pom.xml 调用 testng.xml 文件

我必须在 pom.xml 中制定任何 Maven 规范来检测 testng.xml 文件是否存在并且他们必须阅读它。

I'm not 100% sure about this. In looking at the above example it looks like something like the following is recommended:

我不是 100% 确定这一点。在查看上面的示例时,建议使用以下内容:

<plugin>
    <groupId>org.apache.maven.plugin</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>2.12</version>
    <configuration>
       <suiteXmlFiles>
           <suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>
       </suiteXmlFiles>
    </configuration> 
</plugin>

回答by Mikey

It does not matter where you put as long as you specify the path in your maven pom.xml under maven-surefire-plugin

只要在 maven-surefire-plugin 下的 maven pom.xml 中指定路径即可