Quaatso Education

Home Forums Selenium Forum ignoring my annotation and I am getting pass=0 failed=0 skip=0

ignoring my annotation and I am getting pass=0 failed=0 skip=0

This topic contains 1 reply, has 2 voices, and was last updated by  Nandan Singh 10 months, 1 week ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #4391

    Rahul Mehta
    Participant

    Here is my prog. with @Test annotation along with console output of testng Can you tell me why i am facing this problem?? It is ignoring my annotation and I am getting pass=0 failed=0 skip=0

     

     

    //Prog.

     

    public class Myprog {

     

    int tub[]={1,2,3,4};

    int max = 0;

     

     

    int y = 9;

    int z = 8 ;

     

    @Test

    public int getProductOf(int y, int z)

    {

    int x = y*z;

    return x;

     

     

     

     

    }

     

     

    //TestNg Console output

     

    Method publ

    ic int Myprog.getProductOf(int,int) has a @Test annotation but also a return value: ignoring it. Use <suite allow-return-values=”true”> to fix this

    [TestNG] Running:

    C:\Users\Admin\AppData\Local\Temp\testng-eclipse-1033765656\testng-customsuite.xml

     

    [Utils] Attempting to create A:\workspace\Junit\test-output\Default suite\Default test.xml

    [Utils]   Directory A:\workspace\Junit\test-output\Default suite exists: true

     

    ===============================================

    Default test

    Tests run: 0, Failures: 0, Skips: 0

     

    #4392

    Nandan Singh
    Keymaster

    Rahul, the problem is with the “return” type you provided in the Test Method.

    As per testing standard, your test method should not return any value, as we never call a test case into another test case. So if you change your return type to “void” it will be working fine.

    However, TestNG provides a way by which you can return a value from a test case (not recommended) and according to this you have to set “allow-return-values”=”true” in Suite tag of TestNG.xml.

    Example :

    <suite allow-return-values=”true”>

    // all xml code goes here!!!

    </suite>

    Hope this will resolve your query!!!

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.