Suppress Assert stack trace?

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

Suppress Assert stack trace?

sirdan
Is there a way to suppress the java.lang.AssertionError stack trace that appears in the console when an exception is thrown? It doesn't provide much useful info (i.e. expected [true[ but found ]false]) and it would be nice to have the option to get rid of it, so it doesn't clutter other output. thanks -dan

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/testng-users/-/6x1Gzi1WkvkJ.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en.
Reply | Threaded
Open this post in threaded view
|

Re: Suppress Assert stack trace?

edwolb
I think that this might be implemented by the default TestNG listeners.  Our listeners for example choose what to output to the console.  We actually end up filtering the stack traces to include only code that we have written, which reduces some stack traces from 30+ lines to 3-5 lines.

On Thursday, 22 November 2012 02:35:36 UTC-5, sirdan wrote:
Is there a way to suppress the java.lang.AssertionError stack trace that appears in the console when an exception is thrown? It doesn't provide much useful info (i.e. expected [true[ but found ]false]) and it would be nice to have the option to get rid of it, so it doesn't clutter other output. thanks -dan

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/testng-users/-/7GwdKP5Z0g0J.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en.
Reply | Threaded
Open this post in threaded view
|

Re: Suppress Assert stack trace?

sirdan
Thanks for the suggestion, I'll try it.
Reply | Threaded
Open this post in threaded view
|

Re: Suppress Assert stack trace?

sirdan
For others who encounter this, here's some code that will strip out the stack trace:

import org.testng.ITestResult;

import org.testng.TestListenerAdapter;


public class NoTrace extends TestListenerAdapter {

 

  @Override

  public void onTestFailure(ITestResult tr) 

  {

Throwable thrown = tr.getThrowable();

StackTraceElement[] outTrace = new StackTraceElement[0];

thrown.setStackTrace(outTrace);

  }

 

  @Override

  public void onTestSkipped(ITestResult tr) 

  {

  }

 

  @Override

  public void onTestSuccess(ITestResult tr) 

  {

  }

 

}

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/testng-users/-/YoMDXQBeCg4J.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en.