Skip to content

Commit 0a9bb4a

Browse files
committed
. d updated markdown snippets
1 parent 28ec2f4 commit 0a9bb4a

10 files changed

+28
-28
lines changed

approvaltests-util/docs/ArrayUtils.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
ArrayUtils has the ability to dynamically determine the type of your list.
1313

1414
<!-- snippet: toArray -->
15-
<a id='snippet-toarray'></a>
15+
<a id='snippet-toArray'></a>
1616
```java
1717
List<Comparable> comparables = new ArrayList<>();
1818
comparables.add(null);
@@ -21,18 +21,18 @@ comparables.add(3.1415);
2121
comparables.add("Lars");
2222
Comparable[] comparableArray = ArrayUtils.toArray(comparables);
2323
```
24-
<sup><a href='/approvaltests-util-tests/src/test/java/com/spun/util/ArrayUtilsTest.java#L101-L108' title='Snippet source file'>snippet source</a> | <a href='#snippet-toarray' title='Start of snippet'>anchor</a></sup>
24+
<sup><a href='/approvaltests-util-tests/src/test/java/com/spun/util/ArrayUtilsTest.java#L101-L108' title='Snippet source file'>snippet source</a> | <a href='#snippet-toArray' title='Start of snippet'>anchor</a></sup>
2525
<!-- endSnippet -->
2626

2727
This works in almost all cases with the notable exceptions of empty arrays, some common interfaces
2828
which will not be preferenced.
2929
In which case you can always use the overloaded method
3030
<!-- snippet: toArrayWithClass -->
31-
<a id='snippet-toarraywithclass'></a>
31+
<a id='snippet-toArrayWithClass'></a>
3232
```java
3333
Comparable[] array = ArrayUtils.toArray(comparables, Comparable.class);
3434
```
35-
<sup><a href='/approvaltests-util-tests/src/test/java/com/spun/util/ArrayUtilsTest.java#L109-L111' title='Snippet source file'>snippet source</a> | <a href='#snippet-toarraywithclass' title='Start of snippet'>anchor</a></sup>
35+
<sup><a href='/approvaltests-util-tests/src/test/java/com/spun/util/ArrayUtilsTest.java#L109-L111' title='Snippet source file'>snippet source</a> | <a href='#snippet-toArrayWithClass' title='Start of snippet'>anchor</a></sup>
3636
<!-- endSnippet -->
3737

3838

approvaltests-util/docs/how_to/VarArgsWithAtleastOne.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@ Most solutions for this occur at runtime. Of course, it would be better if they
1919
### Runtime solution
2020

2121
<!-- snippet: minimalVarargsRuntime -->
22-
<a id='snippet-minimalvarargsruntime'></a>
22+
<a id='snippet-minimalVarargsRuntime'></a>
2323
```java
2424
public Integer findSmallest(Integer... numbers)
2525
{
2626
if (numbers == null || numbers.length < 1)
2727
{ throw new IllegalArgumentException("you must have at least one number"); }
2828
// rest of the code
2929
```
30-
<sup><a href='/approvaltests-util-tests/src/test/java/com/spun/util/MinimumVarargSamples.java#L20-L26' title='Snippet source file'>snippet source</a> | <a href='#snippet-minimalvarargsruntime' title='Start of snippet'>anchor</a></sup>
30+
<sup><a href='/approvaltests-util-tests/src/test/java/com/spun/util/MinimumVarargSamples.java#L20-L26' title='Snippet source file'>snippet source</a> | <a href='#snippet-minimalVarargsRuntime' title='Start of snippet'>anchor</a></sup>
3131
<!-- endSnippet -->
3232

3333
### Compile time solution
@@ -37,14 +37,14 @@ If you do this, you will want to recombine this array almost immediately `ArrayU
3737
Please be aware that it will not work with primitives.
3838

3939
<!-- snippet: minimalVarargsCompileTime -->
40-
<a id='snippet-minimalvarargscompiletime'></a>
40+
<a id='snippet-minimalVarargsCompileTime'></a>
4141
```java
4242
public Integer findSmallest(Integer first, Integer... numbers)
4343
{
4444
Integer[] combined = ArrayUtils.combine(first, numbers);
4545
// rest of the code
4646
```
47-
<sup><a href='/approvaltests-util-tests/src/test/java/com/spun/util/MinimumVarargSamples.java#L29-L34' title='Snippet source file'>snippet source</a> | <a href='#snippet-minimalvarargscompiletime' title='Start of snippet'>anchor</a></sup>
47+
<sup><a href='/approvaltests-util-tests/src/test/java/com/spun/util/MinimumVarargSamples.java#L29-L34' title='Snippet source file'>snippet source</a> | <a href='#snippet-minimalVarargsCompileTime' title='Start of snippet'>anchor</a></sup>
4848
<!-- endSnippet -->
4949

5050
### Advantages
@@ -53,11 +53,11 @@ If you use the runtime solution, the following will compile but throw an error w
5353
If you use the compile time solution, it will not compile.
5454

5555
<!-- snippet: minimalVarargsException -->
56-
<a id='snippet-minimalvarargsexception'></a>
56+
<a id='snippet-minimalVarargsException'></a>
5757
```java
5858
int smallest = findSmallest();
5959
```
60-
<sup><a href='/approvaltests-util-tests/src/test/java/com/spun/util/MinimumVarargSamples.java#L12-L14' title='Snippet source file'>snippet source</a> | <a href='#snippet-minimalvarargsexception' title='Start of snippet'>anchor</a></sup>
60+
<sup><a href='/approvaltests-util-tests/src/test/java/com/spun/util/MinimumVarargSamples.java#L12-L14' title='Snippet source file'>snippet source</a> | <a href='#snippet-minimalVarargsException' title='Start of snippet'>anchor</a></sup>
6161
<!-- endSnippet -->
6262

6363
### Where to use this

approvaltests/docs/Scrubbers.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ created at [Date1]
147147
If you need to do scrubbing of multiple things, the easiest way is to create multiple scrubbers and then combine them.
148148

149149
<!-- snippet: MultiScrubber -->
150-
<a id='snippet-multiscrubber'></a>
150+
<a id='snippet-MultiScrubber'></a>
151151
```java
152152
final Scrubber portScrubber = new RegExScrubber(":\\d+/", ":[port]/");
153153
final Scrubber dateScrubber = DateScrubber.getScrubberFor("20210505T091112Z");
@@ -156,7 +156,7 @@ Scrubber scrubber = Scrubbers.scrubAll(portScrubber, dateScrubber, signatureScru
156156
Approvals.verify("http://127.0.0.1:55079/foo/bar?Date=20210505T091112Z&Signature=4a7dd6f09c1e",
157157
new Options(scrubber));
158158
```
159-
<sup><a href='/approvaltests-tests/src/test/java/org/approvaltests/scrubbers/ScrubberTest.java#L47-L54' title='Snippet source file'>snippet source</a> | <a href='#snippet-multiscrubber' title='Start of snippet'>anchor</a></sup>
159+
<sup><a href='/approvaltests-tests/src/test/java/org/approvaltests/scrubbers/ScrubberTest.java#L47-L54' title='Snippet source file'>snippet source</a> | <a href='#snippet-MultiScrubber' title='Start of snippet'>anchor</a></sup>
160160
<!-- endSnippet -->
161161

162162
will result in

approvaltests/docs/how_to/MachineNameSpecificTest.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ It checks if the current machine's name matches the specified name (e.g., ".lars
2222
The actual test code should be placed after this condition.
2323

2424
<!-- snippet: runOnlyOnSpecificMachines -->
25-
<a id='snippet-runonlyonspecificmachines'></a>
25+
<a id='snippet-runOnlyOnSpecificMachines'></a>
2626
```java
2727
try (NamedEnvironment namedEnvironment = NamerFactory.asMachineNameSpecificTest())
2828
{
2929
if (!namedEnvironment.isCurrentEnvironmentValidFor(".lars-mbp-14"))
3030
{ return; }
3131
// the rest of your test...
3232
```
33-
<sup><a href='/approvaltests/src/test/java/org/approvaltests/reporters/intellij/IntelliJPathResolverTest.java#L60-L66' title='Snippet source file'>snippet source</a> | <a href='#snippet-runonlyonspecificmachines' title='Start of snippet'>anchor</a></sup>
33+
<sup><a href='/approvaltests/src/test/java/org/approvaltests/reporters/intellij/IntelliJPathResolverTest.java#L60-L66' title='Snippet source file'>snippet source</a> | <a href='#snippet-runOnlyOnSpecificMachines' title='Start of snippet'>anchor</a></sup>
3434
<!-- endSnippet -->
3535

3636
**please note:** this will also append the machine name to the ApprovalTest so that each specific

approvaltests/docs/how_to/ShowNullsInJson.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ To modify this behavior and display null fields,
99
follow the example provided below.
1010

1111
<!-- snippet: CustomGsonBuilderShowingNull -->
12-
<a id='snippet-customgsonbuildershowingnull'></a>
12+
<a id='snippet-CustomGsonBuilderShowingNull'></a>
1313
```java
1414
Person person = new Person("Max", null, 1);
1515
JsonApprovals.verifyAsJson(person, GsonBuilder::serializeNulls);
1616
```
17-
<sup><a href='/approvaltests-tests/src/test/java/org/approvaltests/JsonFormattingTest.java#L33-L36' title='Snippet source file'>snippet source</a> | <a href='#snippet-customgsonbuildershowingnull' title='Start of snippet'>anchor</a></sup>
17+
<sup><a href='/approvaltests-tests/src/test/java/org/approvaltests/JsonFormattingTest.java#L33-L36' title='Snippet source file'>snippet source</a> | <a href='#snippet-CustomGsonBuilderShowingNull' title='Start of snippet'>anchor</a></sup>
1818
<!-- endSnippet -->

approvaltests/docs/how_to/TestAVarietyOfValues.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ If you have more than one parameter that you want to vary, check out [Testing Co
2020
1. Copy this starter text.
2121

2222
<!-- snippet: VerifyAllStartingPoint -->
23-
<a id='snippet-verifyallstartingpoint'></a>
23+
<a id='snippet-VerifyAllStartingPoint'></a>
2424
```java
2525
String[] inputs = {"input.value1", "input.value2"};
2626
Approvals.verifyAll("TITLE", inputs, s -> "placeholder " + s);
2727
```
28-
<sup><a href='/approvaltests-tests/src/test/java/org/approvaltests/ApprovalsTest.java#L46-L49' title='Snippet source file'>snippet source</a> | <a href='#snippet-verifyallstartingpoint' title='Start of snippet'>anchor</a></sup>
28+
<sup><a href='/approvaltests-tests/src/test/java/org/approvaltests/ApprovalsTest.java#L46-L49' title='Snippet source file'>snippet source</a> | <a href='#snippet-VerifyAllStartingPoint' title='Start of snippet'>anchor</a></sup>
2929
<!-- endSnippet -->
3030

3131
2. Modify the input container for your chosen values.

approvaltests/docs/how_to/TestCombinations.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ If you have only one parameter that you want to vary, check out [How to Test a V
2020
1. Copy this starter text, and adjust for the number of inputs that you have.
2121

2222
<!-- snippet: CombinationsStartingPoint -->
23-
<a id='snippet-combinationsstartingpoint'></a>
23+
<a id='snippet-CombinationsStartingPoint'></a>
2424
```java
2525
String[] inputs1 = {"input1.value1", "input1.value2"};
2626
String[] inputs2 = {"input2.value1", "input2.value2", "input2.value3"};
2727
CombinationApprovals.verifyAllCombinations((a, b) -> "placeholder", inputs1, inputs2);
2828
```
29-
<sup><a href='/approvaltests-tests/src/test/java/org/approvaltests/combinations/CombinationTest.java#L42-L46' title='Snippet source file'>snippet source</a> | <a href='#snippet-combinationsstartingpoint' title='Start of snippet'>anchor</a></sup>
29+
<sup><a href='/approvaltests-tests/src/test/java/org/approvaltests/combinations/CombinationTest.java#L42-L46' title='Snippet source file'>snippet source</a> | <a href='#snippet-CombinationsStartingPoint' title='Start of snippet'>anchor</a></sup>
3030
<!-- endSnippet -->
3131

3232
2. Modify each input container for your chosen values.
@@ -60,13 +60,13 @@ This makes a kind of approval test matrix, automatically testing all combination
6060
In this small example, all combinations of `{"hello", "world"}` and `{1, 2, 3}` are being used:
6161

6262
<!-- snippet: YouCanVerifyCombinationsOf2 -->
63-
<a id='snippet-youcanverifycombinationsof2'></a>
63+
<a id='snippet-YouCanVerifyCombinationsOf2'></a>
6464
```java
6565
String[] strings = {"hello", "world"};
6666
Integer[] numbers = {1, 2, 3};
6767
CombinationApprovals.verifyAllCombinations((s, i) -> String.format("(%s,%s)", s, i), strings, numbers);
6868
```
69-
<sup><a href='/approvaltests-tests/src/test/java/org/approvaltests/combinations/CombinationTest.java#L51-L55' title='Snippet source file'>snippet source</a> | <a href='#snippet-youcanverifycombinationsof2' title='Start of snippet'>anchor</a></sup>
69+
<sup><a href='/approvaltests-tests/src/test/java/org/approvaltests/combinations/CombinationTest.java#L51-L55' title='Snippet source file'>snippet source</a> | <a href='#snippet-YouCanVerifyCombinationsOf2' title='Start of snippet'>anchor</a></sup>
7070
<!-- endSnippet -->
7171

7272
The format is carefully chosen to show both inputs and outputs, to make the test results easy to interpret. The output looks like this:

approvaltests/docs/reference/AwtApprovals.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ To create such a gif you pass the number of frames you want plus a function that
3131
for every frame. Here is an example for a simple expanding box:
3232

3333
<!-- snippet: SequencePaintables -->
34-
<a id='snippet-sequencepaintables'></a>
34+
<a id='snippet-SequencePaintables'></a>
3535
```java
3636
SquareDrawer squareDrawer = new SquareDrawer();
3737
AwtApprovals.verifySequence(5, f -> squareDrawer.setSquareSize(f * 10));
3838
```
39-
<sup><a href='/approvaltests-tests/src/test/java/org/approvaltests/awt/ApprovalsTest.java#L48-L51' title='Snippet source file'>snippet source</a> | <a href='#snippet-sequencepaintables' title='Start of snippet'>anchor</a></sup>
39+
<sup><a href='/approvaltests-tests/src/test/java/org/approvaltests/awt/ApprovalsTest.java#L48-L51' title='Snippet source file'>snippet source</a> | <a href='#snippet-SequencePaintables' title='Start of snippet'>anchor</a></sup>
4040
<!-- endSnippet -->
4141

4242
**Note**: Method overloads allow specifying the time between frames or the time for each frame.

approvaltests/docs/reference/IntelliJReporter.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ This page exists when IntelliJ is not being found in your system.
1919
Currently, here are some of the paths that are supported:
2020

2121
<!-- snippet: SupportedIntelliJPaths -->
22-
<a id='snippet-supportedintellijpaths'></a>
22+
<a id='snippet-SupportedIntelliJPaths'></a>
2323
```java
2424
"/Users/fakeUser/Library/Application Support/JetBrains/Toolbox/apps/IDEA-C/ch-0/223.8617.56/IntelliJ IDEA CE.app/Contents/MacOS/idea",
2525
"/Users/fakeUser/Library/Application Support/JetBrains/Toolbox/apps/IDEA-U/ch-0/223.8617.56/IntelliJ IDEA 2022.2 EAP.app"
2626
```
27-
<sup><a href='/approvaltests/src/test/java/org/approvaltests/reporters/intellij/IntelliJPathResolverTest.java#L79-L82' title='Snippet source file'>snippet source</a> | <a href='#snippet-supportedintellijpaths' title='Start of snippet'>anchor</a></sup>
27+
<sup><a href='/approvaltests/src/test/java/org/approvaltests/reporters/intellij/IntelliJPathResolverTest.java#L79-L82' title='Snippet source file'>snippet source</a> | <a href='#snippet-SupportedIntelliJPaths' title='Start of snippet'>anchor</a></sup>
2828
<!-- endSnippet -->
2929

3030
If IntelliJ is not opening for you,

approvaltests/docs/reference/StoryBoard.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ StoryBoards can be very helpful to tell a story of steps that happen over time.
1313
Here is a simple example
1414

1515
<!-- snippet: StoryBoardExample -->
16-
<a id='snippet-storyboardexample'></a>
16+
<a id='snippet-StoryBoardExample'></a>
1717
```java
1818
Approvals.verify(new StoryBoard().add(gameOfLife).addFrames(3, gameOfLife::advance));
1919
```
20-
<sup><a href='/approvaltests-tests/src/test/java/org/approvaltests/StoryBoardTest.java#L23-L25' title='Snippet source file'>snippet source</a> | <a href='#snippet-storyboardexample' title='Start of snippet'>anchor</a></sup>
20+
<sup><a href='/approvaltests-tests/src/test/java/org/approvaltests/StoryBoardTest.java#L23-L25' title='Snippet source file'>snippet source</a> | <a href='#snippet-StoryBoardExample' title='Start of snippet'>anchor</a></sup>
2121
<!-- endSnippet -->
2222

2323
which produces

0 commit comments

Comments
 (0)