Skip to content

Commit 86d64cf

Browse files
committed
- F improved error message
1 parent 16fecf8 commit 86d64cf

File tree

3 files changed

+30
-21
lines changed

3 files changed

+30
-21
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
org.approvaltests.ApprovalsDuplicateVerifyException: Already approved: file.txt
2-
By default, ApprovalTests only allows one verify() call per test.
3-
To find out more, visit:
4-
https://github.com/approvals/ApprovalTests.Java/blob/master/approvaltests/docs/reference/Naming.md
1+
org.approvaltests.ApprovalsDuplicateVerifyException: By default, ApprovalTests only allows one verify() call per test.
2+
This file has already been approved: file.txt
53

6-
# Fixes
7-
1. separate your test into two tests
8-
2. add NamedParameters with the NamerFactory
9-
3. Override Approvals.settings() with either
10-
a. allowMultipleVerifyCallsForThisClass
11-
b. allowMultipleVerifyCallsForThisMethod
4+
You can do one of the following:
5+
6+
* Separate your test into two tests
7+
* Allow multiple verify calls inside one test class or method via:
8+
- Approvals.settings().allowMultipleVerifyCallsForThisClass();
9+
- Approvals.settings().allowMultipleVerifyCallsForThisMethod();
10+
* Add NamedParameters with the NamerFactory
11+
- visit https://github.com/approvals/ApprovalTests.Java/blob/master/approvaltests/docs/reference/Naming.md

approvaltests-tests/src/test/java/org/approvaltests/inline/InlineApprovalsTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -200,11 +200,11 @@ void testSemiAutomaticMessage()
200200
void testSemiAutomaticWithPreviousApproved()
201201
{
202202
var expected = """
203-
42
204-
***** DELETE ME TO APPROVE *****
205-
vvvvv PREVIOUS RESULT vvvvv
206-
41
207-
""";
203+
42
204+
***** DELETE ME TO APPROVE *****
205+
vvvvv PREVIOUS RESULT vvvvv
206+
41
207+
""";
208208
var options = new Options().inline(expected, InlineOptions.semiAutomaticWithPreviousApproved());
209209
try
210210
{

approvaltests/src/main/java/org/approvaltests/ApprovalsDuplicateVerifyException.java

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,22 @@
22

33
public class ApprovalsDuplicateVerifyException extends RuntimeException
44
{
5+
// @formatter:off
56
public ApprovalsDuplicateVerifyException(String file)
67
{
7-
super("Already approved: " + file + "\n"
8-
+ "By default, ApprovalTests only allows one verify() call per test.\n" + "To find out more, visit: \n"
9-
+ "https://github.com/approvals/ApprovalTests.Java/blob/master/approvaltests/docs/reference/Naming.md\n\n"
10-
+ "# Fixes\n" + "1. separate your test into two tests\n" + "2. add NamedParameters with the NamerFactory\n"
11-
+ "3. Override Approvals.settings() with either \n" + "\ta. allowMultipleVerifyCallsForThisClass\n"
12-
+ "\tb. allowMultipleVerifyCallsForThisMethod");
8+
super(
9+
"By default, ApprovalTests only allows one verify() call per test.\n"
10+
+ "This file has already been approved: " + file + "\n"
11+
+ "\n"
12+
+ "You can do one of the following:\n"
13+
+ "\n"
14+
+ "* Separate your test into two tests\n"
15+
+ "* Allow multiple verify calls inside one test class or method via:\n"
16+
+ "\t- Approvals.settings().allowMultipleVerifyCallsForThisClass();\n"
17+
+ "\t- Approvals.settings().allowMultipleVerifyCallsForThisMethod();\n"
18+
+ "* Add NamedParameters with the NamerFactory\n"
19+
+ "\t- visit https://github.com/approvals/ApprovalTests.Java/blob/master/approvaltests/docs/reference/Naming.md\n"
20+
);
1321
}
22+
// @formatter:on
1423
}

0 commit comments

Comments
 (0)