2

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 

Gafi
  • 61
  • 1
  • 10
  • I must add that running test classes works just fine - tests are executed. – Gafi Feb 05 '21 at 14:45
  • Can you check if there is more relevant error information using [log files](https://intellij-support.jetbrains.com/hc/en-us/articles/207241085-Locating-IDE-log-files)? Probably stacktrace.. – Alexey R. Feb 05 '21 at 17:49
  • Thanks for your response Alexey :] I've added stacktrace to the question. – Gafi Feb 08 '21 at 08:35
  • Okay, I found the source of the error but I don't know why this is not working. In TestNG Run Configuration there is a "Parameters" tab that has "Properties file:" field where I have specified a path to a ".properties" file. This file contains properties that are used by "@Parameters" annotations in my test classes. "Unable to parse suite: InputStream cannot be null" error occurs only when the path to properties is specified and I run the XML file. – Gafi Feb 08 '21 at 12:47
  • What's the source? – Alexey R. Feb 08 '21 at 13:04
  • Running XML while Run Configuration has properties flle path specified - this causes the error but I don't know why it does that. – Gafi Feb 08 '21 at 14:12
  • probably that property holds relative path that starts from unexpected point – Alexey R. Feb 08 '21 at 14:14
  • It does not. I have tried changing this file to only contain the simplest property i.e. "environment=chrome" but error still occurs. – Gafi Feb 08 '21 at 14:24

1 Answers1

1

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

Adrian
  • 2,233
  • 1
  • 22
  • 33
  • Like I said in my comment: "error occurs only when the path to properties is specified and I run the XML file." so yes - removing data from that section causes the error not to appear. Thing is that this solution (properties file used for testng.xml) worked in the past and it has changed after some IntelliJ IDEA update. As of today and version 2021.1 (build #IC-211.6693.111) it does not work. – Gafi Apr 22 '21 at 13:26
  • 1
    I reported this issue to JetBrains support: https://youtrack.jetbrains.com/issue/IDEA-262685 They weren't able to reproduce the issue on their end but logging was added. Should arrive with build 212.261. – Gafi Apr 22 '21 at 13:30
  • 1
    @Gafi I just added this as an answer to make it more obvious, had to go through the questions comments to find the "solution". Btw. your ticket is currently closed as there are some information missing. – Adrian Apr 22 '21 at 13:38
  • 1
    Sure, didn't mean to be rude :] The ticket was created by the support person that I was in contact with. It was closed automatically because they weren't able to reproduce the issue. Like I said, extra logging will be available on future build. – Gafi Apr 22 '21 at 14:02