Skip to content

Commit b912f40

Browse files
committed
d updated markdown snippets
1 parent 0bd0405 commit b912f40

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

approvaltests/docs/Configuration.md

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,11 +143,33 @@ As such ApprovalTests has an algorithm to guess the source file's location.
143143
This works most of the time. In the off chance that it doesn't work for you, you can fix it manually using the following injection point.
144144

145145
### Defining alternatives
146-
snippet: define_alternative_source_directory_finder
146+
<!-- snippet: define_alternative_source_directory_finder -->
147+
<a id='snippet-define_alternative_source_directory_finder'></a>
148+
```java
149+
Function2<Class, String, File> myFinder = new Function2<Class, String, File>()
150+
{
151+
@Override
152+
public File call(Class clazz, String fileName)
153+
{
154+
return new File("src/test/java/" + clazz.getPackage().getName().replaceAll("\\.", File.separator));
155+
}
156+
};
157+
```
158+
<sup><a href='/approvaltests-tests/src/test/java/org/approvaltests/namer/NamerSamples.java#L17-L26' title='Snippet source file'>snippet source</a> | <a href='#snippet-define_alternative_source_directory_finder' title='Start of snippet'>anchor</a></sup>
159+
<!-- endSnippet -->
147160
### Using alternatives
148161
Thanks to the try block, the default is restored afterwards allowing tests to be independent.
149162
You might want to do this at a [higher level](https://stackoverflow.com/questions/43282798/in-junit-5-how-to-run-code-before-all-tests).
150-
snippet: configure_alternative_source_directory
163+
<!-- snippet: configure_alternative_source_directory -->
164+
<a id='snippet-configure_alternative_source_directory'></a>
165+
```java
166+
try (SourceDirectoryRestorer sdr = TestUtils.registerSourceDirectoryFinder(myFinder))
167+
{
168+
Approvals.verify("Ragunath");
169+
}
170+
```
171+
<sup><a href='/approvaltests-tests/src/test/java/org/approvaltests/namer/NamerSamples.java#L28-L33' title='Snippet source file'>snippet source</a> | <a href='#snippet-configure_alternative_source_directory' title='Start of snippet'>anchor</a></sup>
172+
<!-- endSnippet -->
151173

152174
---
153175

0 commit comments

Comments
 (0)