diff --git a/approvaltests-tests/src/test/java/org/approvaltests/ApprovalsDuplicateVerifyExceptionTest.java b/approvaltests-tests/src/test/java/org/approvaltests/ApprovalsDuplicateVerifyExceptionTest.java new file mode 100644 index 00000000..471a4ccc --- /dev/null +++ b/approvaltests-tests/src/test/java/org/approvaltests/ApprovalsDuplicateVerifyExceptionTest.java @@ -0,0 +1,13 @@ +package org.approvaltests; + +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +class ApprovalsDuplicateVerifyExceptionTest { + + @Test + void testExceptionMessage() { + Approvals.verify(new ApprovalsDuplicateVerifyException("file.txt")); + } +} diff --git a/approvaltests-tests/src/test/java/org/approvaltests/ApprovalsDuplicateVerifyExceptionTest.testExceptionMessage.approved.txt b/approvaltests-tests/src/test/java/org/approvaltests/ApprovalsDuplicateVerifyExceptionTest.testExceptionMessage.approved.txt new file mode 100644 index 00000000..b468846f --- /dev/null +++ b/approvaltests-tests/src/test/java/org/approvaltests/ApprovalsDuplicateVerifyExceptionTest.testExceptionMessage.approved.txt @@ -0,0 +1,11 @@ +org.approvaltests.ApprovalsDuplicateVerifyException: Already approved: file.txt +By default, ApprovalTests only allows one verify() call per test. +To find out more, visit: +https://github.com/approvals/ApprovalTests.Java/blob/master/approvaltests/docs/reference/Naming.md + +# Fixes +1. separate your test into two tests +2. add NamedParameters with the NamerFactory +3. Override Approvals.settings() with either + a. allowMultipleVerifyCallsForThisClass + b. allowMultipleVerifyCallsForThisMethod \ No newline at end of file diff --git a/approvaltests/src/main/java/org/approvaltests/ApprovalsDuplicateVerifyException.java b/approvaltests/src/main/java/org/approvaltests/ApprovalsDuplicateVerifyException.java index 33ce4fac..fc25c633 100644 --- a/approvaltests/src/main/java/org/approvaltests/ApprovalsDuplicateVerifyException.java +++ b/approvaltests/src/main/java/org/approvaltests/ApprovalsDuplicateVerifyException.java @@ -6,6 +6,12 @@ public ApprovalsDuplicateVerifyException(String file) { super("Already approved: " + file + "\n" + "By default, ApprovalTests only allows one verify() call per test.\n" + "To find out more, visit: \n" - + "https://github.com/approvals/ApprovalTests.Java/blob/master/approvaltests/docs/reference/Naming.md"); + + "https://github.com/approvals/ApprovalTests.Java/blob/master/approvaltests/docs/reference/Naming.md\n\n" + + "# Fixes\n" + + "1. separate your test into two tests\n" + + "2. add NamedParameters with the NamerFactory\n" + + "3. Override Approvals.settings() with either \n" + + "\ta. allowMultipleVerifyCallsForThisClass\n" + + "\tb. allowMultipleVerifyCallsForThisMethod"); } }