Skip to content

Commit

Permalink
TestOutputDecorator, minor factorisation.
Browse files Browse the repository at this point in the history
  • Loading branch information
marco-brandizi committed Dec 5, 2024
1 parent 75d907b commit 0bf5430
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/main/java/uk/ac/ebi/utils/test/junit/TestOutputDecorator.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,25 @@ public class TestOutputDecorator extends RunListener implements TestRule
{
private Logger log = LoggerFactory.getLogger ( this.getClass () );

/**
* Common head/trail log reporter.
*/
private void decorateTestOutput ( String logFormat, Description testDescriptor )
{
String msg = MessageFormat.format ( logFormat, testDescriptor.getDisplayName () );
log.info ( " " + StringUtils.center ( msg, 110, "=-" ) );
}

@Override
public void testStarted ( Description description ) throws Exception
{
String label = MessageFormat.format ( " {0} ", description.getDisplayName () );
log.info ( " " + StringUtils.center ( label, 110, "=-" ) );
decorateTestOutput ( " {0} ", description );
}

@Override
public void testFinished ( Description description ) throws Exception
{
String label = MessageFormat.format ( " /end: {0} ", description.getDisplayName () );
log.info ( " " + StringUtils.center ( label, 110, "=-" ) + "\n" );
decorateTestOutput ( " /end: {0} ", description );
}

/**
Expand Down

0 comments on commit 0bf5430

Please sign in to comment.