Class ErrorDecorator

java.lang.Object
stack.source.junit4.ErrorDecorator
All Implemented Interfaces:
org.junit.rules.TestRule

public final class ErrorDecorator
extends java.lang.Object
implements org.junit.rules.TestRule
Decorates stack traces with source code snippets.

Example output:


 org.junit.ComparisonFailure: expected:<H[ello]!> but was:<H[i]!>
     at org.junit.Assert.assertEquals(Assert.java:115)
     at example.HelloTest.hello(HelloTest.java:16)

        14      @Test
        15      public void hello() {
     -> 16          assertEquals("Hello!", greet());
        17      }

 ...
 

Usage:


 public class BaseTest {
   @Rule
   public final ErrorDecorator errorDecorator = new ErrorDecorator();
 }

 public final class MyTest extends BaseTest {
   @Test
   public void myTest() {
     // ...
   }
 }
 
  • Constructor Summary

    Constructors 
    Constructor Description
    ErrorDecorator()  
  • Method Summary

    Modifier and Type Method Description
    org.junit.runners.model.Statement apply​(org.junit.runners.model.Statement base, org.junit.runner.Description description)  

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • apply

      public org.junit.runners.model.Statement apply​(org.junit.runners.model.Statement base, org.junit.runner.Description description)
      Specified by:
      apply in interface org.junit.rules.TestRule