Skip to content

Commit

Permalink
Introduce ApprovalTests (https://approvaltests.com/)
Browse files Browse the repository at this point in the history
- It opens a diff window when comparing Strings and File contents
  • Loading branch information
gastaldi committed Jul 9, 2024
1 parent 2d98a64 commit 7eef513
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 1 deletion.
10 changes: 10 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
<assertj.version>3.21.0</assertj.version>
<spotless.version>2.12.2</spotless.version>
<google-java-format.version>1.7</google-java-format.version>
<approvaltests.version>24.2.0</approvaltests.version>
</properties>

<dependencies>
Expand All @@ -49,6 +50,12 @@
<version>${assertj.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.approvaltests</groupId>
<artifactId>approvaltests</artifactId>
<version>${approvaltests.version}</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand All @@ -66,6 +73,9 @@
<include>.gitignore</include>
<include>.gitattributes</include>
</includes>
<excludes>
<exclude>src/test/approvals/**</exclude>
</excludes>
<trimTrailingWhitespace />
<endWithNewline />
<indent>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#comment1
# comment2

! comment3
one=simple
two=value containing spaces
# another comment
! and a comment
! block
three=and escapes\n\t\r\f
\ with\ spaces = everywhere
altsep:value
multiline = one \
two \
three
key.4 = \u1234\u1234
# final comment
12 changes: 12 additions & 0 deletions src/test/java/org/codejive/properties/PackageSettings.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package org.codejive.properties;

/**
* This class is used by the ApprovalTests framework
*
* @see <a
* href="https://github.com/approvals/ApprovalTests.Java/blob/master/approvaltests/docs/Configuration.md#package-level-settings">ApprovalTests
* Configuration</a>
*/
public class PackageSettings {
public static String ApprovalBaseDirectory = "../approvals";
}
3 changes: 2 additions & 1 deletion src/test/java/org/codejive/properties/TestProperties.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import java.util.Collections;
import java.util.Iterator;
import java.util.NoSuchElementException;
import org.approvaltests.Approvals;
import org.junit.jupiter.api.Test;

public class TestProperties {
Expand Down Expand Up @@ -124,7 +125,7 @@ void testStoreOutputStream() throws IOException, URISyntaxException {
Properties p = Properties.loadProperties(f);
ByteArrayOutputStream os = new ByteArrayOutputStream();
p.store(os);
assertThat(os.toString()).isEqualTo(readAll(f));
Approvals.verify(os.toString());
}

@Test
Expand Down

0 comments on commit 7eef513

Please sign in to comment.