Welcome to minuteTest

minuteTest is a collection of utility code for unit testing. If you do write a lot of unit test code in your projects, certain problems tend to surface again and again. This toolbox provides a generic solution to some of these little itches, because repeating yourself is so DRY.

This is a subproject of minuteTools, but can be used independently.


Download the current version of minuteTools.

Features and usage examples

Validation of String objects against a Golden Master file

Everytime you generate a sizeable amount of text content (can be everything from an elaborate error message to a complex XML fragment), you will not want to verify the outcome "on foot". GoldenMasterFile enables you to easily verify your string against a static text file. E.g. using JUnit, you can write:

  assertEquals(hugeString, goldenMasterFile(this, "SampleGoldenMaster.txt"));

See the unit test GoldenMasterFileTest for a more complete example.

log4j appender implementation for unit tests

If you are serious about your logging activities, you will want to unit test at least the more critical parts of them. But how can you verify, the content of your log in your unit test? Using a specialized appender implementation for log4j accessing the log content becomes easy:


You can also define more than one appender and access them by their names:


A sample log4j configuration for testing could look like this:

<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">

   <appender name="unitTestAppender" 
      <layout class="org.apache.log4j.PatternLayout">
         <param name="ConversionPattern" value="%-5p  [%c{1}] %m %n" />

  <appender name="infoTestAppender" 
      <param name="Threshold" value="INFO" />
      <layout class="org.apache.log4j.PatternLayout">
         <param name="ConversionPattern" value="%-5p  [%c{1}] %m %n" />

   <logger name="com.minutefforts.test.util.logging.UnitTestAppenderTest">   
      <appender-ref ref="infoTestAppender"/>    

        <priority value="debug" />
        <appender-ref ref="unitTestAppender" />

See the unit test UnitTestAppenderTest for a complete usage example.

One final remark: Exceptions are logged without stack trace to make verification easier.

Feedback is welcome

Any feedback is welcome - questions, critique, praise and suggestions alike. :-)

Sent email to achim[at]minutefforts.com.