ParentPathMapper

public class ParentPathMapper<T> implements PathMapper<T>

A path mapper that will put all approvals in a common parent path. Let’s say you want to put all your approval results in src/test/resources/approval(we assume a common maven directory structure) then you can use this mapper as follows:

Approval approval = Approval.of(String.class)
 .withPathMapper(new ParentPathMapper(Paths.get("src/test/resources/approval")))
 .build();

now the following call

approval.verify("Some cool string value", Paths.get("some_cool_value.txt");

will put the approved value in the file src/test/resources/approval/some_cool_value.txt

Parameters:
  • <T> – the value that will be approved

Constructors

ParentPathMapper

public ParentPathMapper(Path parentPath)

Creates a parent path mapper that puts approvals in the given parent path.

Parameters:
  • parentPath – the parent path for all approvals

Methods

getPath

public Path getPath(T value, Path approvalFilePath)