简体   繁体   English

TestNG - 尝试运行 XML 文件时出现“无法解析套件”错误

[英]TestNG - “Unable to parse suite” error when trying to run an XML file

I am developing a test automation project using: IntelliJ, Maven, TestNG and Selenium Webdriver.我正在使用 IntelliJ、Maven、TestNG 和 Selenium Webdriver 开发一个测试自动化项目。 The problem is that I am unable to run XML suite files.问题是我无法运行 XML 套件文件。 Right-clicking on such file gives me the option to run them but it fails with error: Unable to parse suite: InputStream cannot be null右键单击此类文件为我提供了运行它们的选项,但它失败并出现错误: Unable to parse suite: InputStream cannot be null

There is no more info provided.没有提供更多信息。 TestNG plugin is installed and active. TestNG 插件已安装并处于活动状态。 Run Configuration has TestNG option.运行配置具有 TestNG 选项。

Here is the XML file that I am trying to run:这是我要运行的 XML 文件:

<!DOCTYPE suite SYSTEM "https://testng.org/testng-1.0.dtd">

<suite name="All Test Suite" verbose="1">
    <parameter name="environment" value="chrome"/>
    <parameter name="remoteRun" value="false"/>

    <test name="Regression12">
        <classes>
            <class name="tests.SampleTest"/>
        </classes>
    </test>
</suite>

I was looking for an answer online but there is not much and none of the solutions work in my case.我一直在网上寻找答案,但没有多少,而且没有一个解决方案适用于我的情况。 I was trying to change the location of the XML files but I didn't change anything.我试图更改 XML 文件的位置,但我没有更改任何内容。

Thanks for the help and please tell me if I should provide some more info.感谢您的帮助,请告诉我是否应该提供更多信息。

IntelliJ version is 2020.3.2 - no updates for IDE or plugins are available so everything is up to date. IntelliJ 版本是 2020.3.2 - IDE 没有更新或插件可用,因此一切都是最新的。 I'm running it on Windows 10.我在 Windows 10 上运行它。

Update: Here is the stacktrace from IntelliJ after running an XML file.更新:这是运行 XML 文件后来自 IntelliJ 的堆栈跟踪。 There is one error regarding "SLF4J" dependency (logging) but I don't think it's related to my problem.关于“SLF4J”依赖(日志记录)有一个错误,但我认为这与我的问题无关。

2021-02-08 09:10:23,605 [ 282317]   INFO - ij.compiler.impl.CompileDriver - COMPILATION STARTED (BUILD PROCESS) 
2021-02-08 09:10:23,609 [ 282321]   INFO - j.compiler.server.BuildManager - Using preloaded build process to compile C:/Users/customname/IdeaProjects/customname-project-automated-tests 
2021-02-08 09:10:23,781 [ 282493]   INFO - lij.compiler.impl.CompilerUtil -     COMPILATION FINISHED (BUILD PROCESS); Errors: 0; warnings: 0 took 186 ms: 0 min 0sec 
2021-02-08 09:10:24,713 [ 283425]   INFO - j.compiler.server.BuildManager - BUILDER_PROCESS [stdout]: Build process started. Classpath: C:/Program Files/JetBrains/IntelliJ IDEA Community Edition 2020.3.2/plugins/java/lib/jps-launcher.jar 
2021-02-08 09:10:24,799 [ 283511]   INFO - j.compiler.server.BuildManager - BUILDER_PROCESS [stderr]: SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". 
2021-02-08 09:10:24,800 [ 283512]   INFO - j.compiler.server.BuildManager - BUILDER_PROCESS [stderr]: SLF4J: Defaulting to no-operation (NOP) logger implementation 
2021-02-08 09:10:24,800 [ 283512]   INFO - j.compiler.server.BuildManager - BUILDER_PROCESS [stderr]: SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details. 
2021-02-08 09:10:26,197 [ 284909]   INFO - j.compiler.server.BuildManager - BUILDER_PROCESS [stderr]: WARNING: An illegal reflective access operation has occurred 
2021-02-08 09:10:26,197 [ 284909]   INFO - j.compiler.server.BuildManager - BUILDER_PROCESS [stderr]: WARNING: Illegal reflective access by com.intellij.util.ReflectionUtil (file:/C:/Program%20Files/JetBrains/IntelliJ%20IDEA%20Community%20Edition%202020.3.2/lib/util.jar) to method java.util.ResourceBundle.setParent(java.util.ResourceBundle) 
2021-02-08 09:10:26,197 [ 284909]   INFO - j.compiler.server.BuildManager - BUILDER_PROCESS [stderr]: WARNING: Please consider reporting this to the maintainers of com.intellij.util.ReflectionUtil 
2021-02-08 09:10:26,197 [ 284909]   INFO - j.compiler.server.BuildManager - BUILDER_PROCESS [stderr]: WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations 
2021-02-08 09:10:26,197 [ 284909]   INFO - j.compiler.server.BuildManager - BUILDER_PROCESS [stderr]: WARNING: All illegal access operations will be denied in a future release 
2021-02-08 09:10:29,381 [ 288093]   INFO - rationStore.ComponentStoreImpl - Saving Project(name=TestNGTemplateProject, containerState=COMPONENT_CREATED, componentStore=C:\Users\customname\IdeaProjects\customname-project-automated-tests)Kotlin2JvmCompilerArguments took 20 ms 

<tl/dr>: Remove the custom parameters/ properties file from the Run configration in IntelliJ and add all needed parameters in the XML file. <tl/dr>:从 IntelliJ 中的Run configration中删除自定义参数/属性文件,并在 XML 文件中添加所有需要的参数。

在此处输入图像描述

For me the problem was, that I have a custom default TestNG configuration with some parameters preconfigured.对我来说,问题是,我有一个自定义的默认 TestNG 配置,并预先配置了一些参数。 This seems not to work with TestNG XML files.这似乎不适用于 TestNG XML 文件。

Props: the comment of Gafi give me the final tip.道具:加菲的评论给了我最后的提示。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM