Skip to content

Commit 09e4631

Browse files
committed
d Add docs for VerifyAll
1 parent 496fc7f commit 09e4631

File tree

5 files changed

+74
-3
lines changed

5 files changed

+74
-3
lines changed

approvaltests-tests/src/test/java/org/approvaltests/ApprovalsTest.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,12 @@ public void testWrongCall()
3434
Approvals.verify(b, new Options(new QuietReporter()));
3535
});
3636
}
37+
38+
@Test
39+
void verifyAllTemplate() {
40+
// begin-snippet: VerifyAllStartingPoint
41+
String[] inputs = {"input.value1", "input.value2"};
42+
Approvals.verifyAll("TITLE", inputs,s -> "placeholder " + s);
43+
// end-snippet
44+
}
3745
}

approvaltests/docs/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
* have [Consistent Time Zones](how_to/ConsistentTimeZones.md#top) in your tests
2525
* separate and test [Data Access and Rendering](how_to/PatternsForTestingDataAccessAndRendering.md#top)
2626
* show [nulls in verifyAsJson](how_to/ShowNullsInJson.md#top)
27+
* [test a variety of values](reference/CombinationApprovals.md)
2728

2829
## Configuration
2930

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<a id="top"></a>
2+
3+
# How to Test a Variety of Values for One Input
4+
5+
<!-- toc -->
6+
## Contents
7+
8+
* [When to use Approvals::verifyAll()](#when-to-use-approvalsverifyall)
9+
* [Steps](#steps)<!-- endToc -->
10+
11+
## When to use Approvals::verifyAll()
12+
13+
When you want to test a lot of variations for a single input value.
14+
15+
If you have more than one parameter that you want to vary, check out [Testing Combinations](/docs/how_to/TestingCombinations.md#top).
16+
17+
## Steps
18+
19+
1. Copy this starter text.
20+
21+
<!-- snippet: VerifyAllStartingPoint -->
22+
<a id='snippet-verifyallstartingpoint'></a>
23+
```java
24+
String[] inputs = {"input.value1", "input.value2"};
25+
Approvals.verifyAll("TITLE", inputs,s -> "placeholder " + s);
26+
```
27+
<sup><a href='/approvaltests-tests/src/test/java/org/approvaltests/ApprovalsTest.java#L40-L43' title='Snippet source file'>snippet source</a> | <a href='#snippet-verifyallstartingpoint' title='Start of snippet'>anchor</a></sup>
28+
<!-- endSnippet -->
29+
30+
2. Modify the input container for your chosen values.
31+
3. Run it, and make sure that you have your inputs wired up correctly.
32+
33+
If they are wired up correctly, you will see a file that looks like this: the lambda is responsible for both the execution and formatting of the result.
34+
35+
<!-- snippet: ApprovalsTest.verifyAllTemplate.approved.txt -->
36+
<a id='snippet-ApprovalsTest.verifyAllTemplate.approved.txt'></a>
37+
```txt
38+
TITLE
39+
40+
41+
placeholder input.value1
42+
placeholder input.value2
43+
```
44+
<sup><a href='/approvaltests-tests/src/test/java/org/approvaltests/ApprovalsTest.verifyAllTemplate.approved.txt#L1-L5' title='Snippet source file'>snippet source</a> | <a href='#snippet-ApprovalsTest.verifyAllTemplate.approved.txt' title='Start of snippet'>anchor</a></sup>
45+
<!-- endSnippet -->
46+
47+
4. Replace the "placeholder" with a call to the functionality that you want to test.
48+
5. Change the TITLE to something meaningful
49+
6. Run it, and approve the output.
50+
51+
---
52+
53+
[Back to User Guide](/doc/README.md#top)

approvaltests/docs/how_to/TestCombinations.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@
77

88
* [When to use Combinations](#when-to-use-combinations)
99
* [Steps](#steps)
10-
* [The Basics](#the-basics)
11-
* [Passing in a Reporter](#passing-in-a-reporter)
12-
* [C++ Language Versions](#c-language-versions)<!-- endToc -->
10+
* [The Basics](#the-basics)<!-- endToc -->
1311

1412
## When to use Combinations
1513

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
toc
2+
3+
## Verifying a Variety of Inputs
4+
5+
* [A variety of inputs for a single parameter](/docs/how_to/TestAVarietyOfValues.md)
6+
* [A variety of inputs for multiple parameters](/docs/how_to/TestCombinations.md)
7+
* [A minimum set of inputs for multiple parameters](/docs/Features.md#combinationapprovalsverifybestcoveringpairs)
8+
9+
10+
11+

0 commit comments

Comments
 (0)