Skip to content

Commit

Permalink
add example characterization test (#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielRamosAcosta authored Oct 29, 2023
1 parent 68a1e56 commit c102873
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
21 changes: 21 additions & 0 deletions src/test/java/org/example/ExampleCollaboratorTest.java
Original file line number Diff line number Diff line change
@@ -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);
}
}
16 changes: 16 additions & 0 deletions src/test/java/org/example/ExampleCollaboratorTest.sum.approved.txt
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit c102873

Please sign in to comment.