TestNG - "Unable to parse suite" error when trying to run an XML file

Viewed 1855

I am developing a test automation project using: IntelliJ, Maven, TestNG and Selenium Webdriver. The problem is that I am unable to run XML suite files. 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

There is no more info provided. TestNG plugin is installed and active. Run Configuration has TestNG option.

Here is the XML file that I am trying to run:

<!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.

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. I'm running it on Windows 10.

Update: Here is the stacktrace from IntelliJ after running an XML file. There is one error regarding "SLF4J" dependency (logging) but I don't think it's related to my problem.

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 

1 Answers

<tl/dr>: Remove the custom parameters/ properties file from the Run configration in IntelliJ and add all needed parameters in the XML file.

enter image description here

For me the problem was, that I have a custom default TestNG configuration with some parameters preconfigured. This seems not to work with TestNG XML files.

Props: the comment of Gafi give me the final tip.

Related