Reports will have not correct information | Selenium Forum
M
Posted on 18/10/2015
Hi Ashish,

Please try to understand my issue. As per module 20, we can put all of our errors/failures in excel file. The problem is that if I use ErrorUtil.addVerificationFailure(t) then only it will write in excel file. Now suppose , I am not able to open the browser so I wrote Assert.fail("No need to go ahead"); as I dont want to continue further. I have not collected the error because I dont want to continue sp in the xls report I will not have any information abt this as I have not used "ErrorUtil.addVerificationFailure(t)"

So, my problem is that my code will always consist of "ErrorUtil.addVerificationFailure(t)" and "Assert.fail" depending on the situation but my xls report will not have all the information. So , how to deal with such situation


package Roughwork;

import java.util.List;

import org.testng.Assert;

import com.qtpselenium.framework.datadriven.util.ErrorUtil;

public class UnderstandingAssertion {

public static void main(String[] args) {

try{


OpenBrowser(xpath)
}catch(Throwable t)
{
Assert.fail("No need to go ahead");
}

System.out.println("Hello");
try{

Assert.assertTrue(false,"B failed");
}catch(Throwable t)
{
ErrorUtil.addVerificationFailure(t);

}

List<String> a=ErrorUtil.getVerificationFailures();
System.out.println(a.size());
System.out.println(a);

}

}


o/p
Exception in thread "main" java.lang.AssertionError: No need to go ahead
at org.testng.Assert.fail(Assert.java:94)
at Roughwork.UnderstandingAssertion.main(UnderstandingAssertion.java:19)

M
Replied on 20/10/2015

hi,
instead of this
[quote:y3lim586]try{

Assert.assertTrue(false,"B failed");
}catch(Throwable t)
{
ErrorUtil.addVerificationFailure(t);

}
[/quote:y3lim586]

you have to write your own logic something like this


[quote:y3lim586]try{

Assert.assertTrue(false,"B failed");
}catch(Throwable t)
{
ErrorUtil.addVerificationFailure(t);

}

if(error==some specific error){
Assert.assertTrue(false,"B failed");
}

[/quote:y3lim586]


M
Replied on 22/10/2015

Hi,

The below code of yours will not give all errors. What I want that once my all test complete running then the information in xls file i.e Hashtable and in the reprot which generated automatically (XLST) should be same.

But it will never happen because xls file or Hashtable will have information about errors only if I use "ErrorUtil.addVerificationFailure(t);" but everywhere it is not possible to use ErrorUtil.addVerificationFailure(t);

You can see your below example as well that once u used "ErrorUtil.addVerificationFailure(t);" and on next time u used Assert only without try catch

I want 1 pattern which we should follow so that I will not miss any errors on all the reports which gets generated

try{

Assert.assertTrue(false,"B failed");
}catch(Throwable t)
{
ErrorUtil.addVerificationFailure(t);

}

if(error==some specific error){
Assert.assertTrue(false,"B failed");
}


M
Replied on 23/10/2015

you say you want to add errors to reports.

you have to do that with "ErrorUtil.addVerificationFailure(t);" there is no other way.




and its not "xls file" its "xsl file"

xls = microsoft excel
xsl = reports