How to specify a test with method name, class name and parameters in testng.xml?

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

How to specify a test with method name, class name and parameters in testng.xml?

akshay.maldhure

I wish to have test level parameters in my testng.xml and below is the code present in my testng.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="My Test Suite" verbose="1">
   <parameter name="param1" value="value1" />
   <parameter name="param2" value="value2" />
   <listeners>
      <listener class-name="TestListener" />
   </listeners>
   <test name="Test1">
      <parameter name="param" value="value" />
      <classes>
         <class name="ClassContainingTest1" />
         <methods>
            <include name="test1" />
         </methods>
      </classes>
   </test>
   <test name="Test2">
      <parameter name="param" value="value" />
      <classes>
         <class name="ClassContainingTest2" />
         <methods>
            <include name="test2" />
         </methods>
      </classes>
   </test>
</suite>

But the XML editor highlights the classes tag in red. It seems something is wrong with my XML structure, but I'm unable to figure out the same.

Please help.

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How to specify a test with method name, class name and parameters in testng.xml?

Vimal Raj
The methods should be the child of class, not the classes.


On 5 June 2017 at 15:46, <[hidden email]> wrote:

I wish to have test level parameters in my testng.xml and below is the code present in my testng.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="My Test Suite" verbose="1">
   <parameter name="param1" value="value1" />
   <parameter name="param2" value="value2" />
   <listeners>
      <listener class-name="TestListener" />
   </listeners>
   <test name="Test1">
      <parameter name="param" value="value" />
      <classes>
         <class name="ClassContainingTest1" />
         <methods>
            <include name="test1" />
         </methods>
      </classes>
   </test>
   <test name="Test2">
      <parameter name="param" value="value" />
      <classes>
         <class name="ClassContainingTest2" />
         <methods>
            <include name="test2" />
         </methods>
      </classes>
   </test>
</suite>

But the XML editor highlights the classes tag in red. It seems something is wrong with my XML structure, but I'm unable to figure out the same.

Please help.

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How to specify a test with method name, class name and parameters in testng.xml?

akshay.maldhure
Hi Vimal,

Thanks for your response. I did not understand it completely. It would be great if you could mentioned the correct XML structure for one of those tests.

On Monday, June 5, 2017 at 3:52:34 PM UTC+5:30, Vimal Raj wrote:
The methods should be the child of class, not the classes.



Thanks
Vimalraj
<a href="http://vimalselvam.com" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fvimalselvam.com\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNE8qo3EUnfhohY8BQN46BcvIf5dMQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fvimalselvam.com\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNE8qo3EUnfhohY8BQN46BcvIf5dMQ&#39;;return true;">http://vimalselvam.com
<a href="https://www.gitshowcase.com/email2vimalraj" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.gitshowcase.com%2Femail2vimalraj\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNF7BjYGhnOR-SHREYGzSxUddkZsuA&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.gitshowcase.com%2Femail2vimalraj\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNF7BjYGhnOR-SHREYGzSxUddkZsuA&#39;;return true;">https://www.gitshowcase.com/email2vimalraj


On 5 June 2017 at 15:46, <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="0EIOZxn-BQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">akshay....@...> wrote:

I wish to have test level parameters in my testng.xml and below is the code present in my testng.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "<a href="http://testng.org/testng-1.0.dtd" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Ftestng.org%2Ftestng-1.0.dtd\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFHihXzQ1YlwcxcDehnw97TuniFLA&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Ftestng.org%2Ftestng-1.0.dtd\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFHihXzQ1YlwcxcDehnw97TuniFLA&#39;;return true;">http://testng.org/testng-1.0.dtd">
<suite name="My Test Suite" verbose="1">
   <parameter name="param1" value="value1" />
   <parameter name="param2" value="value2" />
   <listeners>
      <listener class-name="TestListener" />
   </listeners>
   <test name="Test1">
      <parameter name="param" value="value" />
      <classes>
         <class name="ClassContainingTest1" />
         <methods>
            <include name="test1" />
         </methods>
      </classes>
   </test>
   <test name="Test2">
      <parameter name="param" value="value" />
      <classes>
         <class name="ClassContainingTest2" />
         <methods>
            <include name="test2" />
         </methods>
      </classes>
   </test>
</suite>

But the XML editor highlights the classes tag in red. It seems something is wrong with my XML structure, but I'm unable to figure out the same.

Please help.

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="0EIOZxn-BQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">testng-users...@googlegroups.com.
To post to this group, send email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="0EIOZxn-BQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">testng...@....
Visit this group at <a href="https://groups.google.com/group/testng-users" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/group/testng-users&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/group/testng-users&#39;;return true;">https://groups.google.com/group/testng-users.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How to specify a test with method name, class name and parameters in testng.xml?

⇜Krishnan Mahadevan⇝

Change your xml to as below and try again.

The methods tag should be enclosed with the class tag and should not be outside it.

 

<?xml version="1.0" encoding="UTF-8"?>

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

<suite name="My Test Suite" verbose="1">

    <parameter name="param1" value="value1"/>

    <parameter name="param2" value="value2"/>

    <listeners>

        <listener class-name="TestListener"/>

    </listeners>

    <test name="Test1">

        <parameter name="param" value="value"/>

        <classes>

            <class name="ClassContainingTest1">

                <methods>

                    <include name="test1"/>

                </methods>

            </class>

        </classes>

    </test>

    <test name="Test2">

        <parameter name="param" value="value"/>

        <classes>

            <class name="ClassContainingTest2">

                <methods>

                    <include name="test2"/>

                </methods>

            </class>

        </classes>

    </test>

</suite>

 

 

 

Thanks & Regards

Krishnan Mahadevan

 

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"

My Scribblings @ http://wakened-cognition.blogspot.com/

My Technical Scribbings @ http://rationaleemotions.wordpress.com/

 

From: <[hidden email]> on behalf of <[hidden email]>
Reply-To: <[hidden email]>
Date: Tuesday, June 6, 2017 at 10:19 AM
To: testng-users <[hidden email]>
Subject: Re: [testng-users] How to specify a test with method name, class name and parameters in testng.xml?

 

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="My Test Suite" verbose="1">
   <parameter name="param1" value="value1" />
   <parameter name="param2" value="value2" />
   <listeners>
      <listener class-name="TestListener" />
   </listeners>
   <test name="Test1">
      <parameter name="param" value="value" />
      <classes>
         <class name="ClassContainingTest1" />
         <methods>
            <include name="test1" />
         </methods>
      </classes>
   </test>
   <test name="Test2">
      <parameter name="param" value="value" />
      <classes>
         <class name="ClassContainingTest2" />
         <methods>
            <include name="test2" />
         </methods>
      </classes>
   </test>
</suite>

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How to specify a test with method name, class name and parameters in testng.xml?

akshay.maldhure
Thanks Krishnan! It seems I was making a basic syntactic mistake in the XML file. I'm facing another issue now with the dependency. My test2 is dependent on test1 (i.e. I've mentioned the dependsOnMethods={"test1"} in the @Test of test2).

TestNG throws below exception in this case:
test2() is depending on method public void package.ClassContainingTest1.test1(java.lang.String), which is not annotated with @Test or not included.

I have no idea why I'm facing this. Do you have any pointers?

On Tuesday, June 6, 2017 at 10:23:08 AM UTC+5:30, Krishnan wrote:

Change your xml to as below and try again.

The methods tag should be enclosed with the class tag and should not be outside it.

 

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE suite SYSTEM "<a href="http://testng.org/testng-1.0.dtd" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Ftestng.org%2Ftestng-1.0.dtd\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFHihXzQ1YlwcxcDehnw97TuniFLA&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Ftestng.org%2Ftestng-1.0.dtd\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFHihXzQ1YlwcxcDehnw97TuniFLA&#39;;return true;">http://testng.org/testng-1.0.dtd">

<suite name="My Test Suite" verbose="1">

    <parameter name="param1" value="value1"/>

    <parameter name="param2" value="value2"/>

    <listeners>

        <listener class-name="TestListener"/>

    </listeners>

    <test name="Test1">

        <parameter name="param" value="value"/>

        <classes>

            <class name="ClassContainingTest1">

                <methods>

                    <include name="test1"/>

                </methods>

            </class>

        </classes>

    </test>

    <test name="Test2">

        <parameter name="param" value="value"/>

        <classes>

            <class name="ClassContainingTest2">

                <methods>

                    <include name="test2"/>

                </methods>

            </class>

        </classes>

    </test>

</suite>

 

 

 

Thanks & Regards

Krishnan Mahadevan

 

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"

My Scribblings @ <a href="http://wakened-cognition.blogspot.com/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwakened-cognition.blogspot.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHzOdYJCASIDF_28vQtkp9gnKAYSQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwakened-cognition.blogspot.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHzOdYJCASIDF_28vQtkp9gnKAYSQ&#39;;return true;">http://wakened-cognition.blogspot.com/

My Technical Scribbings @ <a href="http://rationaleemotions.wordpress.com/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Frationaleemotions.wordpress.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEcBOKyRn0lpL8LDbBuyAlKdwgXwQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Frationaleemotions.wordpress.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEcBOKyRn0lpL8LDbBuyAlKdwgXwQ&#39;;return true;">http://rationaleemotions.wordpress.com/

 

From: <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="kCxEA7Q6BgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">testng...@...> on behalf of <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="kCxEA7Q6BgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">akshay....@...>
Reply-To: <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="kCxEA7Q6BgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">testng...@...>
Date: Tuesday, June 6, 2017 at 10:19 AM
To: testng-users <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="kCxEA7Q6BgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">testng...@...>
Subject: Re: [testng-users] How to specify a test with method name, class name and parameters in testng.xml?

 

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "<a href="http://testng.org/testng-1.0.dtd" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Ftestng.org%2Ftestng-1.0.dtd\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFHihXzQ1YlwcxcDehnw97TuniFLA&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Ftestng.org%2Ftestng-1.0.dtd\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFHihXzQ1YlwcxcDehnw97TuniFLA&#39;;return true;">http://testng.org/testng-1.0.dtd">
<suite name="My Test Suite" verbose="1">
   <parameter name="param1" value="value1" />
   <parameter name="param2" value="value2" />
   <listeners>
      <listener class-name="TestListener" />
   </listeners>
   <test name="Test1">
      <parameter name="param" value="value" />
      <classes>
         <class name="ClassContainingTest1" />
         <methods>
            <include name="test1" />
         </methods>
      </classes>
   </test>
   <test name="Test2">
      <parameter name="param" value="value" />
      <classes>
         <class name="ClassContainingTest2" />
         <methods>
            <include name="test2" />
         </methods>
      </classes>
   </test>
</suite>

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How to specify a test with method name, class name and parameters in testng.xml?

⇜Krishnan Mahadevan⇝

Can you please help share a working sample and also the error details so that we can understand a bit more context around your problem ?

 

Thanks & Regards

Krishnan Mahadevan

 

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"

My Scribblings @ http://wakened-cognition.blogspot.com/

My Technical Scribbings @ http://rationaleemotions.wordpress.com/

 

From: <[hidden email]> on behalf of <[hidden email]>
Reply-To: <[hidden email]>
Date: Tuesday, June 6, 2017 at 11:35 AM
To: testng-users <[hidden email]>
Subject: Re: [testng-users] How to specify a test with method name, class name and parameters in testng.xml?

 

Thanks Krishnan! It seems I was making a basic syntactic mistake in the XML file. I'm facing another issue now with the dependency. My test2 is dependent on test1 (i.e. I've mentioned the dependsOnMethods={"test1"} in the @Test of test2).

 

TestNG throws below exception in this case:

test2() is depending on method public void package.ClassContainingTest1.test1(java.lang.String), which is not annotated with @Test or not included.

 

I have no idea why I'm facing this. Do you have any pointers?


On Tuesday, June 6, 2017 at 10:23:08 AM UTC+5:30, Krishnan wrote:

Change your xml to as below and try again.

The methods tag should be enclosed with the class tag and should not be outside it.

 

<?xml version="1.0" encoding="UTF-8"?>

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

<suite name="My Test Suite" verbose="1">

    <parameter name="param1" value="value1"/>

    <parameter name="param2" value="value2"/>

    <listeners>

        <listener class-name="TestListener"/>

    </listeners>

    <test name="Test1">

        <parameter name="param" value="value"/>

        <classes>

            <class name="ClassContainingTest1">

                <methods>

                    <include name="test1"/>

                </methods>

            </class>

        </classes>

    </test>

    <test name="Test2">

        <parameter name="param" value="value"/>

        <classes>

            <class name="ClassContainingTest2">

                <methods>

                    <include name="test2"/>

                </methods>

            </class>

        </classes>

    </test>

</suite>

 

 

 

Thanks & Regards

Krishnan Mahadevan

 

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"

My Scribblings @ http://wakened-cognition.blogspot.com/

My Technical Scribbings @ http://rationaleemotions.wordpress.com/

 

From: <<a href="javascript:" target="_blank">testng...@...> on behalf of <<a href="javascript:" target="_blank">akshay....@...>
Reply-To: <<a href="javascript:" target="_blank">testng...@...>
Date: Tuesday, June 6, 2017 at 10:19 AM
To: testng-users <<a href="javascript:" target="_blank">testng...@...>
Subject: Re: [testng-users] How to specify a test with method name, class name and parameters in testng.xml?

 

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="My Test Suite" verbose="1">
   <parameter name="param1" value="value1" />
   <parameter name="param2" value="value2" />
   <listeners>
      <listener class-name="TestListener" />
   </listeners>
   <test name="Test1">
      <parameter name="param" value="value" />
      <classes>
         <class name="ClassContainingTest1" />
         <methods>
            <include name="test1" />
         </methods>
      </classes>
   </test>
   <test name="Test2">
      <parameter name="param" value="value" />
      <classes>
         <class name="ClassContainingTest2" />
         <methods>
            <include name="test2" />
         </methods>
      </classes>
   </test>
</suite>

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How to specify a test with method name, class name and parameters in testng.xml?

akshay.maldhure
Here's the code that's not working. The same code works fine if I remove the dependsOnMethods code from the test class.

Test class:
public class SomeClass {
 
 
@Test (priority=1)
 
@Parameters ({"source"})
 
public void test1(String source) {
 
System.out.println("Inside test1");
 
}
 
 
@Test (priority=2, dependsOnMethods = {"test1"})
 
@Parameters ({"source"})
 
public void test2(String source) {
 
System.out.println("Inside test2");
 
}
 
 
@Test (priority=3, dependsOnMethods = {"test2"})
 
public void test3() {
 
System.out.println("Inside test3");
 
}
}


testng.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="AVS - CRM API Tests" verbose="1">
   
<parameter name="param" value="globalValue" />
   
<test name="test1">
     
<parameter name="param" value="localValue1" />
     
<classes>
         
<class name="package.SomeClass">
           
<methods>
               
<include name="test1" />
           
</methods>
         
</class>
     
</classes>
   
</test>
   
<test name="test2">
     
<parameter name="param" value="localValue2" />
     
<classes>
         
<class name="package.SomeClass">
           
<methods>
               
<include name="test2" />
           
</methods>
         
</class>
     
</classes>
   
</test>
   
<test name="test3">
     
<parameter name="param" value="localValue3" />
     
<classes>
         
<class name="package.SomeClass">
           
<methods>
               
<include name="test3" />
           
</methods>
         
</class>
     
</classes>
   
</test>
</suite>



On Tuesday, June 6, 2017 at 11:37:26 AM UTC+5:30, Krishnan wrote:

Can you please help share a working sample and also the error details so that we can understand a bit more context around your problem ?

 

Thanks & Regards

Krishnan Mahadevan

 

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"

My Scribblings @ <a href="http://wakened-cognition.blogspot.com/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwakened-cognition.blogspot.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHzOdYJCASIDF_28vQtkp9gnKAYSQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwakened-cognition.blogspot.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHzOdYJCASIDF_28vQtkp9gnKAYSQ&#39;;return true;">http://wakened-cognition.blogspot.com/

My Technical Scribbings @ <a href="http://rationaleemotions.wordpress.com/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Frationaleemotions.wordpress.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEcBOKyRn0lpL8LDbBuyAlKdwgXwQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Frationaleemotions.wordpress.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEcBOKyRn0lpL8LDbBuyAlKdwgXwQ&#39;;return true;">http://rationaleemotions.wordpress.com/

 

From: <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="2r0L2ME-BgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">testng...@...> on behalf of <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="2r0L2ME-BgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">akshay....@...>
Reply-To: <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="2r0L2ME-BgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">testng...@...>
Date: Tuesday, June 6, 2017 at 11:35 AM
To: testng-users <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="2r0L2ME-BgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">testng...@...>
Subject: Re: [testng-users] How to specify a test with method name, class name and parameters in testng.xml?

 

Thanks Krishnan! It seems I was making a basic syntactic mistake in the XML file. I'm facing another issue now with the dependency. My test2 is dependent on test1 (i.e. I've mentioned the dependsOnMethods={"test1"} in the @Test of test2).

 

TestNG throws below exception in this case:

test2() is depending on method public void package.ClassContainingTest1.test1(java.lang.String), which is not annotated with @Test or not included.

 

I have no idea why I'm facing this. Do you have any pointers?


On Tuesday, June 6, 2017 at 10:23:08 AM UTC+5:30, Krishnan wrote:

Change your xml to as below and try again.

The methods tag should be enclosed with the class tag and should not be outside it.

 

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE suite SYSTEM "<a href="http://testng.org/testng-1.0.dtd" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Ftestng.org%2Ftestng-1.0.dtd\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFHihXzQ1YlwcxcDehnw97TuniFLA&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Ftestng.org%2Ftestng-1.0.dtd\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFHihXzQ1YlwcxcDehnw97TuniFLA&#39;;return true;">http://testng.org/testng-1.0.dtd">

<suite name="My Test Suite" verbose="1">

    <parameter name="param1" value="value1"/>

    <parameter name="param2" value="value2"/>

    <listeners>

        <listener class-name="TestListener"/>

    </listeners>

    <test name="Test1">

        <parameter name="param" value="value"/>

        <classes>

            <class name="ClassContainingTest1">

                <methods>

                    <include name="test1"/>

                </methods>

            </class>

        </classes>

    </test>

    <test name="Test2">

        <parameter name="param" value="value"/>

        <classes>

            <class name="ClassContainingTest2">

                <methods>

                    <include name="test2"/>

                </methods>

            </class>

        </classes>

    </test>

</suite>

 

 

 

Thanks & Regards

Krishnan Mahadevan

 

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"

My Scribblings @ <a href="http://wakened-cognition.blogspot.com/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwakened-cognition.blogspot.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHzOdYJCASIDF_28vQtkp9gnKAYSQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwakened-cognition.blogspot.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHzOdYJCASIDF_28vQtkp9gnKAYSQ&#39;;return true;">http://wakened-cognition.blogspot.com/

My Technical Scribbings @ <a href="http://rationaleemotions.wordpress.com/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Frationaleemotions.wordpress.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEcBOKyRn0lpL8LDbBuyAlKdwgXwQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Frationaleemotions.wordpress.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEcBOKyRn0lpL8LDbBuyAlKdwgXwQ&#39;;return true;">http://rationaleemotions.wordpress.com/

 

From: <[hidden email]> on behalf of <[hidden email]>
Reply-To: <[hidden email]>
Date: Tuesday, June 6, 2017 at 10:19 AM
To: testng-users <[hidden email]>
Subject: Re: [testng-users] How to specify a test with method name, class name and parameters in testng.xml?

 

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "<a href="http://testng.org/testng-1.0.dtd" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Ftestng.org%2Ftestng-1.0.dtd\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFHihXzQ1YlwcxcDehnw97TuniFLA&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Ftestng.org%2Ftestng-1.0.dtd\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFHihXzQ1YlwcxcDehnw97TuniFLA&#39;;return true;">http://testng.org/testng-1.0.dtd">
<suite name="My Test Suite" verbose="1">
   <parameter name="param1" value="value1" />
   <parameter name="param2" value="value2" />
   <listeners>
      <listener class-name="TestListener" />
   </listeners>
   <test name="Test1">
      <parameter name="param" value="value" />
      <classes>
         <class name="ClassContainingTest1" />
         <methods>
            <include name="test1" />
         </methods>
      </classes>
   </test>
   <test name="Test2">
      <parameter name="param" value="value" />
      <classes>
         <class name="ClassContainingTest2" />
         <methods>
            <include name="test2" />
         </methods>
      </classes>
   </test>
</suite>

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="2r0L2ME-BgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">testng-users...@googlegroups.com.
To post to this group, send email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="2r0L2ME-BgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">testng...@....
Visit this group at <a href="https://groups.google.com/group/testng-users" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/group/testng-users&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/group/testng-users&#39;;return true;">https://groups.google.com/group/testng-users.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How to specify a test with method name, class name and parameters in testng.xml?

akshay.maldhure
So if dependsOnMethods code is present in SomeClass, below exception is thrown by TestNG:

test2() is depending on method public void package.SomeClass.test1(java.lang.String), which is not annotated with @Test or not included.



On Tuesday, June 6, 2017 at 11:48:28 AM UTC+5:30, [hidden email] wrote:
Here's the code that's not working. The same code works fine if I remove the dependsOnMethods code from the test class.

Test class:
public class SomeClass {
 
 
@Test (priority=1)
 
@Parameters ({"source"})
 
public void test1(String source) {
 
System.out.println("Inside test1");
 
}
 
 
@Test (priority=2, dependsOnMethods = {"test1"})
 
@Parameters ({"source"})
 
public void test2(String source) {
 
System.out.println("Inside test2");
 
}
 
 
@Test (priority=3, dependsOnMethods = {"test2"})
 
public void test3() {
 
System.out.println("Inside test3");
 
}
}


testng.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "<a href="http://testng.org/testng-1.0.dtd" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Ftestng.org%2Ftestng-1.0.dtd\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFHihXzQ1YlwcxcDehnw97TuniFLA&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Ftestng.org%2Ftestng-1.0.dtd\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFHihXzQ1YlwcxcDehnw97TuniFLA&#39;;return true;">http://testng.org/testng-1.0.dtd">
<suite name="AVS - CRM API Tests" verbose="1">
   
<parameter name="param" value="globalValue" />
   
<test name="test1">
     
<parameter name="param" value="localValue1" />
     
<classes>
         
<class name="package.SomeClass">
           
<methods>
               
<include name="test1" />
           
</methods>
         
</class>
     
</classes>
   
</test>
   
<test name="test2">
     
<parameter name="param" value="localValue2" />
     
<classes>
         
<class name="package.SomeClass">
           
<methods>
               
<include name="test2" />
           
</methods>
         
</class>
     
</classes>
   
</test>
   
<test name="test3">
     
<parameter name="param" value="localValue3" />
     
<classes>
         
<class name="package.SomeClass">
           
<methods>
               
<include name="test3" />
           
</methods>
         
</class>
     
</classes>
   
</test>
</suite>



On Tuesday, June 6, 2017 at 11:37:26 AM UTC+5:30, Krishnan wrote:

Can you please help share a working sample and also the error details so that we can understand a bit more context around your problem ?

 

Thanks & Regards

Krishnan Mahadevan

 

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"

My Scribblings @ <a href="http://wakened-cognition.blogspot.com/" rel="nofollow" target="_blank" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwakened-cognition.blogspot.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHzOdYJCASIDF_28vQtkp9gnKAYSQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwakened-cognition.blogspot.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHzOdYJCASIDF_28vQtkp9gnKAYSQ&#39;;return true;">http://wakened-cognition.blogspot.com/

My Technical Scribbings @ <a href="http://rationaleemotions.wordpress.com/" rel="nofollow" target="_blank" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Frationaleemotions.wordpress.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEcBOKyRn0lpL8LDbBuyAlKdwgXwQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Frationaleemotions.wordpress.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEcBOKyRn0lpL8LDbBuyAlKdwgXwQ&#39;;return true;">http://rationaleemotions.wordpress.com/

 

From: <[hidden email]> on behalf of <[hidden email]>
Reply-To: <[hidden email]>
Date: Tuesday, June 6, 2017 at 11:35 AM
To: testng-users <[hidden email]>
Subject: Re: [testng-users] How to specify a test with method name, class name and parameters in testng.xml?

 

Thanks Krishnan! It seems I was making a basic syntactic mistake in the XML file. I'm facing another issue now with the dependency. My test2 is dependent on test1 (i.e. I've mentioned the dependsOnMethods={"test1"} in the @Test of test2).

 

TestNG throws below exception in this case:

test2() is depending on method public void package.ClassContainingTest1.test1(java.lang.String), which is not annotated with @Test or not included.

 

I have no idea why I'm facing this. Do you have any pointers?


On Tuesday, June 6, 2017 at 10:23:08 AM UTC+5:30, Krishnan wrote:

Change your xml to as below and try again.

The methods tag should be enclosed with the class tag and should not be outside it.

 

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE suite SYSTEM "<a href="http://testng.org/testng-1.0.dtd" rel="nofollow" target="_blank" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Ftestng.org%2Ftestng-1.0.dtd\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFHihXzQ1YlwcxcDehnw97TuniFLA&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Ftestng.org%2Ftestng-1.0.dtd\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFHihXzQ1YlwcxcDehnw97TuniFLA&#39;;return true;">http://testng.org/testng-1.0.dtd">

<suite name="My Test Suite" verbose="1">

    <parameter name="param1" value="value1"/>

    <parameter name="param2" value="value2"/>

    <listeners>

        <listener class-name="TestListener"/>

    </listeners>

    <test name="Test1">

        <parameter name="param" value="value"/>

        <classes>

            <class name="ClassContainingTest1">

<p class

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How to specify a test with method name, class name and parameters in testng.xml?

⇜Krishnan Mahadevan⇝

Yes. I think TestNG is working as designed here.

You would need to include everything when there’s a dependency within a <test> tag (or) you might want to try using the attribute “ignoreMissingDependencies=true” (This attribute is false by default). This will cause TestNG to suppress these sort of edit checks.

 

 

Thanks & Regards

Krishnan Mahadevan

 

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"

My Scribblings @ http://wakened-cognition.blogspot.com/

My Technical Scribbings @ http://rationaleemotions.wordpress.com/

 

From: <[hidden email]> on behalf of <[hidden email]>
Reply-To: <[hidden email]>
Date: Tuesday, June 6, 2017 at 11:51 AM
To: testng-users <[hidden email]>
Subject: Re: [testng-users] How to specify a test with method name, class name and parameters in testng.xml?

 

So if dependsOnMethods code is present in SomeClass, below exception is thrown by TestNG:

 

test2() is depending on method public void package.SomeClass.test1(java.lang.String), which is not annotated with @Test or not included.




On Tuesday, June 6, 2017 at 11:48:28 AM UTC+5:30, [hidden email] wrote:

Here's the code that's not working. The same code works fine if I remove the dependsOnMethods code from the test class.

 

Test class:

public class SomeClass {
 
 
@Test (priority=1)
 
@Parameters ({"source"})
 
public void test1(String source) {
 
System.out.println("Inside test1");
 
}
 
 
@Test (priority=2, dependsOnMethods = {"test1"})
 
@Parameters ({"source"})
 
public void test2(String source) {
 
System.out.println("Inside test2");
 
}
 
 
@Test (priority=3, dependsOnMethods = {"test2"})
 
public void test3() {
 
System.out.println("Inside test3");
 
}
}

 

 

testng.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="AVS - CRM API Tests" verbose="1">
   
<parameter name="param" value="globalValue" />
   
<test name="test1">
     
<parameter name="param" value="localValue1" />
     
<classes>
         
<class name="package.SomeClass">
           
<methods>
               
<include name="test1" />
           
</methods>
         
</class>
     
</classes>
   
</test>
   
<test name="test2">
     
<parameter name="param" value="localValue2" />
     
<classes>
         
<class name="package.SomeClass">
           
<methods>
               
<include name="test2" />
           
</methods>
         
</class>
     
</classes>
   
</test>
   
<test name="test3">
     
<parameter name="param" value="localValue3" />
     
<classes>
         
<class name="package.SomeClass">
           
<methods>
               
<include name="test3" />
           
</methods>
         
</class>
     
</classes>
   
</test>
</suite>

 

 


On Tuesday, June 6, 2017 at 11:37:26 AM UTC+5:30, Krishnan wrote:

Can you please help share a working sample and also the error details so that we can understand a bit more context around your problem ?

 

Thanks & Regards

Krishnan Mahadevan

 

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"

My Scribblings @ http://wakened-cognition.blogspot.com/

My Technical Scribbings @ http://rationaleemotions.wordpress.com/

 

From: <[hidden email]> on behalf of <[hidden email]>
Reply-To: <[hidden email]>
Date: Tuesday, June 6, 2017 at 11:35 AM
To: testng-users <[hidden email]>
Subject: Re: [testng-users] How to specify a test with method name, class name and parameters in testng.xml?

 

Thanks Krishnan! It seems I was making a basic syntactic mistake in the XML file. I'm facing another issue now with the dependency. My test2 is dependent on test1 (i.e. I've mentioned the dependsOnMethods={"test1"} in the @Test of test2).

 

TestNG throws below exception in this case:

test2() is depending on method public void package.ClassContainingTest1.test1(java.lang.String), which is not annotated with @Test or not included.

 

I have no idea why I'm facing this. Do you have any pointers?


On Tuesday, June 6, 2017 at 10:23:08 AM UTC+5:30, Krishnan wrote:

Change your xml to as below and try again.

The methods tag should be enclosed with the class tag and should not be outside it.

 

<?xml version="1.0" encoding="UTF-8"?>

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

<suite name="My Test Suite" verbose="1">

    <parameter name="param1" value="value1"/>

    <parameter name="param2" value="value2"/>

    <listeners>

        <listener class-name="TestListener"/>

    </listeners>

    <test name="Test1">

        <parameter name="param" value="value"/>

        <classes>

            <class name="ClassContainingTest1">

<p class

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How to specify a test with method name, class name and parameters in testng.xml?

akshay.maldhure
Thanks Krishnan for your inputs! I think I'll go ahead with the first solution of including a set of interdependent tests everything inside a single <test> tag since this approach best suits my requirement, the trade-off being I won't be able to have different parameters for each and every test with this approach. Thanks again!

On Tuesday, June 6, 2017 at 12:15:59 PM UTC+5:30, Krishnan wrote:

Yes. I think TestNG is working as designed here.

You would need to include everything when there’s a dependency within a <test> tag (or) you might want to try using the attribute “ignoreMissingDependencies=true” (This attribute is false by default). This will cause TestNG to suppress these sort of edit checks.

 

 

Thanks & Regards

Krishnan Mahadevan

 

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"

My Scribblings @ <a href="http://wakened-cognition.blogspot.com/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwakened-cognition.blogspot.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHzOdYJCASIDF_28vQtkp9gnKAYSQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwakened-cognition.blogspot.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHzOdYJCASIDF_28vQtkp9gnKAYSQ&#39;;return true;">http://wakened-cognition.blogspot.com/

My Technical Scribbings @ <a href="http://rationaleemotions.wordpress.com/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Frationaleemotions.wordpress.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEcBOKyRn0lpL8LDbBuyAlKdwgXwQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Frationaleemotions.wordpress.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEcBOKyRn0lpL8LDbBuyAlKdwgXwQ&#39;;return true;">http://rationaleemotions.wordpress.com/

 

From: <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="-ZiBYdxABgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">testng...@...> on behalf of <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="-ZiBYdxABgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">akshay....@...>
Reply-To: <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="-ZiBYdxABgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">testng...@...>
Date: Tuesday, June 6, 2017 at 11:51 AM
To: testng-users <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="-ZiBYdxABgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">testng...@...>
Subject: Re: [testng-users] How to specify a test with method name, class name and parameters in testng.xml?

 

So if dependsOnMethods code is present in SomeClass, below exception is thrown by TestNG:

 

test2() is depending on method public void package.SomeClass.test1(java.lang.String), which is not annotated with @Test or not included.




On Tuesday, June 6, 2017 at 11:48:28 AM UTC+5:30, [hidden email] wrote:

Here's the code that's not working. The same code works fine if I remove the dependsOnMethods code from the test class.

 

Test class:

public class SomeClass {
 
 
@Test (priority=1)
 
@Parameters ({"source"})
 
public void test1(String source) {
 
System.out.println("Inside test1");
 
}
 
 
@Test (priority=2, dependsOnMethods = {"test1"})
 
@Parameters ({"source"})
 
public void test2(String source) {
 
System.out.println("Inside test2");
 
}
 
 
@Test (priority=3, dependsOnMethods = {"test2"})
 
public void test3() {
 
System.out.println("Inside test3");
 
}
}

 

 

testng.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "<a href="http://testng.org/testng-1.0.dtd" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Ftestng.org%2Ftestng-1.0.dtd\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFHihXzQ1YlwcxcDehnw97TuniFLA&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Ftestng.org%2Ftestng-1.0.dtd\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFHihXzQ1YlwcxcDehnw97TuniFLA&#39;;return true;">http://testng.org/testng-1.0.dtd">
<suite name="AVS - CRM API Tests" verbose="1">
   
<parameter name="param" value="globalValue" />
   
<test name="test1">
     
<parameter name="param" value="localValue1" />
     
<classes>
         
<class name="package.SomeClass">
           
<methods>
               
<include name="test1" />
           
</methods>
         
</class>
     
</classes>
   
</test>
   
<test name="test2">
     
<parameter name="param" value="localValue2" />
     
<classes>
         
<class name="package.SomeClass">
           
<methods>
               
<include name="test2" />
           
</methods>
         
</class>
     
</classes>
   
</test>
   
<test name="test3">
     
<parameter name="param" value="localValue3" />
     
<classes>
         
<class name="package.SomeClass">
           
<methods>
               
<include name="test3" />
           
</methods>
         
</class>
     
</classes>
   
</test>
</suite>

 

 


On Tuesday, June 6, 2017 at 11:37:26 AM UTC+5:30, Krishnan wrote:

Can you please help share a working sample and also the error details so that we can understand a bit more context around your problem ?

 

Thanks & Regards

Krishnan Mahadevan

 

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"

My Scribblings @ <a href="http://wakened-cognition.blogspot.com/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwakened-cognition.blogspot.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHzOdYJCASIDF_28vQtkp9gnKAYSQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwakened-cognition.blogspot.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHzOdYJCASIDF_28vQtkp9gnKAYSQ&#39;;return true;">http://wakened-cognition.blogspot.com/

My Technical Scribbings @ <a href="http://rationaleemotions.wordpress.com/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Frationaleemotions.wordpress.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEcBOKyRn0lpL8LDbBuyAlKdwgXwQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Frationaleemotions.wordpress.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEcBOKyRn0lpL8LDbBuyAlKdwgXwQ&#39;;return true;">http://rationaleemotions.wordpress.com/

 

From: <[hidden email]> on behalf of <[hidden email]>
Reply-To: <[hidden email]>
Date: Tuesday, June 6, 2017 at 11:35 AM
To: testng-users <[hidden email]>
Subject: Re: [testng-users] How to specify a test with method name, class name and parameters in testng.xml?

 

Thanks Krishnan! It seems I was making a basic syntactic mistake in the XML file. I'm facing another issue now with the dependency. My test2 is dependent on test1 (i.e. I've mentioned the dependsOnMethods={"test1"} in the @Test of test2).

 

TestNG throws below exception in this case:

test2() is depending on method public void package.ClassContainingTest1.test1(java.lang.String), which is not annotated with @Test or not included.

 

I have no idea why I'm facing this. Do you have any pointers?


On Tuesday, June 6, 2017 at 10:23:08 AM UTC+5:30, Krishnan wrote:

Change your xml to as below and try again.

The methods tag should be enclosed with the class tag and should not be outside it.

 

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE suite SYSTEM "<a href="http://testng.org/testng-1.0.dtd" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Ftestng.org%2Ftestng-1.0.dtd\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFHihXzQ1YlwcxcDehnw97TuniFLA&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Ftestng.org%2Ftestng-1.0.dtd\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFHihXzQ1YlwcxcDehnw97TuniFLA&#39;;return true;">http://testng.org/testng-1.0.dtd">

<suite name="My Test Suite" verbose="1">

    <parameter name="param1" value="value1"/>

    <parameter name="param2" value="value2"/>

    <listeners>

        <listener class-name="TestListener"/>

    </listeners>

    <test name="Test1">

        <parameter name="param" value="value"/>

        <classes>

            <class name="ClassContainingTest1">

<p class

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="-ZiBYdxABgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">testng-users...@googlegroups.com.
To post to this group, send email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="-ZiBYdxABgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">testng...@....
Visit this group at <a href="https://groups.google.com/group/testng-users" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/group/testng-users&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/group/testng-users&#39;;return true;">https://groups.google.com/group/testng-users.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.