testng failures

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

testng failures

Tony Chamberlain
Hi

We had a person working for us who recently left.  He did all the testng/Java programming and development for us.  For each test he had a java file with test steps like this:


String result = k.executeKeywords("TestName", data);

           if(result.equals("Pass"))
  {    
           datatable.setCellData("Test Cases", "Actual Result", testRowVal+1, "Test Execution success");
           datatable.setCellData("Test Cases", "Pass/Fail", testRowVal+1, result);    
  }
  else{
datatable.setCellData("Test Cases", "Actual Result", testRowVal+1, "Test ExecutionFailed");
datatable.setCellData("Test Cases", "Pass/Fail", testRowVal+1, "Fail");
                // HERE
   }
Then this would return to testng.  So his output would say that the test failed and it would update the excel file (as you see in code above) with the status that it failed.  BUT testng was still reporting success.  I couldn't figure out for the longest time, but then after some debugging I found something that might work (and seems to with my test).  Where it says "// HERE" in the code above I want to add the following line:

throw new InvocationTargetException(new Exception("Test Failed"));
     
Is there any potential problems doing this?  Does this seem like a good solution?

--
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 http://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: testng failures

praveen133t
Why not use Assert.fail("A Detailed Message")

On Tuesday, June 10, 2014 10:20:27 AM UTC-5, Tony Chamberlain wrote:
Hi

We had a person working for us who recently left.  He did all the testng/Java programming and development for us.  For each test he had a java file with test steps like this:


String result = k.executeKeywords("TestName", data);

           if(result.equals("Pass"))
  {    
           datatable.setCellData("Test Cases", "Actual Result", testRowVal+1, "Test Execution success");
           datatable.setCellData("Test Cases", "Pass/Fail", testRowVal+1, result);    
  }
  else{
datatable.setCellData("Test Cases", "Actual Result", testRowVal+1, "Test ExecutionFailed");
datatable.setCellData("Test Cases", "Pass/Fail", testRowVal+1, "Fail");
                // HERE
   }
Then this would return to testng.  So his output would say that the test failed and it would update the excel file (as you see in code above) with the status that it failed.  BUT testng was still reporting success.  I couldn't figure out for the longest time, but then after some debugging I found something that might work (and seems to with my test).  Where it says "// HERE" in the code above I want to add the following line:

throw new InvocationTargetException(new Exception("Test Failed"));
     
Is there any potential problems doing this?  Does this seem like a good solution?

--
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 http://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.