diff --git a/build.gradle.kts b/build.gradle.kts index 82f87bc..07e9f8b 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -14,6 +14,7 @@ dependencies { testImplementation("org.junit.jupiter:junit-jupiter") testImplementation("org.assertj:assertj-core:3.24.2") testImplementation("org.mockito:mockito-core:5.6.0") + testImplementation("com.approvaltests:approvaltests:22.2.0") } tasks.test { diff --git a/src/test/java/org/example/ExampleCollaboratorTest.java b/src/test/java/org/example/ExampleCollaboratorTest.java new file mode 100644 index 0000000..26f36d3 --- /dev/null +++ b/src/test/java/org/example/ExampleCollaboratorTest.java @@ -0,0 +1,21 @@ +package org.example; + +import org.approvaltests.combinations.CombinationApprovals; +import org.junit.jupiter.api.Test; + +class ExampleCollaboratorTest { + + @Test + void sum() { + CombinationApprovals.verifyAllCombinations( + this::doSum, + new Integer[] {-1, 2, 3, 4}, + new Integer[] {-1, 2, 3, 4} + ); + } + + private int doSum(final Integer a, final Integer b) { + final ExampleCollaborator exampleCollaborator = new ExampleCollaborator(); + return exampleCollaborator.sum(a, b); + } +} \ No newline at end of file diff --git a/src/test/java/org/example/ExampleCollaboratorTest.sum.approved.txt b/src/test/java/org/example/ExampleCollaboratorTest.sum.approved.txt new file mode 100644 index 0000000..00cea10 --- /dev/null +++ b/src/test/java/org/example/ExampleCollaboratorTest.sum.approved.txt @@ -0,0 +1,16 @@ +[-1, -1] => -2 +[-1, 2] => 1 +[-1, 3] => 2 +[-1, 4] => 3 +[2, -1] => 1 +[2, 2] => 4 +[2, 3] => 5 +[2, 4] => 6 +[3, -1] => 2 +[3, 2] => 5 +[3, 3] => 6 +[3, 4] => 7 +[4, -1] => 3 +[4, 2] => 6 +[4, 3] => 7 +[4, 4] => 8