JunitPathMapper

public class JunitPathMapper implements TestRule, PathMapper, FullPathMapper

A path mapper that have to be declared as a org.junit.Rule and will use the standard junit mechanisms to put your approval results in $package-name-with-slashes/$classname/$methodname.

This class can be used as a com.nikolavp.approval.PathMapper in which case it will put your approval results in that directory or you can use it as a com.nikolavp.approval.FullPathMapper in which case your approval result for the single virifacion will be put in a file with that path. In the latter case you will have to make sure that there aren’t two approvals for a single test method.

Constructors

JunitPathMapper

public JunitPathMapper(Path parentPath)

A parent path in which you want to put your approvals if any.

Parameters:
  • parentPath – the parent path

Methods

apply

public Statement apply(Statement base, Description description)

getApprovalPath

public Path getApprovalPath(Object value)

getCurrentTestPath

Path getCurrentTestPath()

getPath

public Path getPath(Object value, Path approvalFilePath)