testng-team / testng

TestNG testing framework
https://testng.org
Apache License 2.0
1.99k stars 1.02k forks source link

ENTITY parent doesn't work when running tests by "TestNG Test" #626

Open jedrzej-andrykowski opened 9 years ago

jedrzej-andrykowski commented 9 years ago

Hello,

I have xml with some parameters (childXML/base.xml):

<?xml version="1.0" encoding="UTF-8"?>
<parameter name="baseUrl" value="https://someurl.com"></parameter>
<parameter name="pass" value="sel"></parameter>

and I want to use these parameters in some suite xml (testng.xml):

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" 
[
<!ENTITY parent SYSTEM "src/main/resources/childXML/base.xml">
]>
<suite name="suite" verbose="2">
    <parmeters>&parent;</parmeters>

    <parameter name="ex" value="123"></parameter>

    <!-- TESTS -->
    <test name="test">
        <packages>
            <package name="tests" />
        </packages>
    </test>

</suite>

I use Eclipse Luna with TestNG plugin. I added testng.xml to the Windows -> Preferences -> TestNG -> Template XML File. When I run tests by TestNG Suite (right click on the testng.xml - > Run as -> TestNG Suite) everything works well. Problem appears when I try to run test by TestNG Test (right click on the project or test class -> Run as -> TestNG Test). I got this error:

java.io.FileNotFoundException: C:\eclipse\src\main\resources\childXML\base.xml

It seems that problem is in the relative path:

<!ENTITY parent SYSTEM "src/main/resources/childXML/base.xml">

I try with other combinations childXML/base.xml, ./childXML/base.xml, but it doesn't work. Maybe I doing something wrong, but I think it is a problem with TestNG or with the plugin.

Thank you in advance

juherr commented 9 years ago

I don't know how you expect it should work, but neither <parmeters> nor <parameters> are supported by TestNG.

srufle commented 9 years ago

http://xml.silmaril.ie/includes.html shows that it should be possible to do what you want, but as @juherr said you should remove the <parmeters> tag because that is not correct testng markup.

Loshadushka commented 9 years ago

You need to mention the module: moduleName/src/main/resources/childXML/base.xml or absolute uri:

 <!ENTITY parent SYSTEM "file:///C:/any_folders_to_your_project/module/selenium-tests/src/test/resources/childXML/base.xml">

3 / in the uri is not a mistake!

Now should work