Wednesday, 8 February 2017

SELENIUM TESTNG: Allow-return-values in TestNG:

Allow-return-values in TestNG:


The Test Methods annotated with @Test that are happen to return a value will be ignored, until you specify allow-return-values =true in testng.xml file.
Example:
package com.rameshsoft.rameshselenium;

import org.testng.annotations.AfterMethod;
import org.testng.annotations.Test;


public class AllowRetunValuesDemo {
    @Test
    static public String display()
    {
         System.out.println("WELCOME TO RAMESHSOFT");
        
         return "RameshSoft";
    }
    @Test
    public void method( )
   
    {
         String s=AllowRetunValuesDemo.display();
         System.out.println(s);
    }

}

testng.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Suite1" allow-return-values="true">
  <test name="Test" allow-return-values="true">
    <classes>
      <class name="com.rameshsoft.rameshselenium.AllowRetunValuesDemo"/>
    </classes>
  </test> <!-- Test -->
</suite> <!-- Suite -->
 

No comments:

Post a Comment