Skip to content

Commit bf9b225

Browse files
committed
Introduce ApprovalTests (https://approvaltests.com/)
- It opens a diff window when comparing Strings and File contents
1 parent d219226 commit bf9b225

File tree

4 files changed

+41
-1
lines changed

4 files changed

+41
-1
lines changed

pom.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
<assertj.version>3.21.0</assertj.version>
3535
<spotless.version>2.12.2</spotless.version>
3636
<google-java-format.version>1.7</google-java-format.version>
37+
<approvaltests.version>24.2.0</approvaltests.version>
3738
</properties>
3839

3940
<dependencies>
@@ -49,6 +50,12 @@
4950
<version>${assertj.version}</version>
5051
<scope>test</scope>
5152
</dependency>
53+
<dependency>
54+
<groupId>com.approvaltests</groupId>
55+
<artifactId>approvaltests</artifactId>
56+
<version>${approvaltests.version}</version>
57+
<scope>test</scope>
58+
</dependency>
5259
</dependencies>
5360

5461
<build>
@@ -66,6 +73,9 @@
6673
<include>.gitignore</include>
6774
<include>.gitattributes</include>
6875
</includes>
76+
<excludes>
77+
<exclude>src/test/approvals/**</exclude>
78+
</excludes>
6979
<trimTrailingWhitespace />
7080
<endWithNewline />
7181
<indent>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#comment1
2+
# comment2
3+
4+
! comment3
5+
one=simple
6+
two=value containing spaces
7+
# another comment
8+
! and a comment
9+
! block
10+
three=and escapes\n\t\r\f
11+
\ with\ spaces = everywhere
12+
altsep:value
13+
multiline = one \
14+
two \
15+
three
16+
key.4 = \u1234\u1234
17+
# final comment
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package org.codejive.properties;
2+
3+
/**
4+
* This class is used by the ApprovalTests framework
5+
*
6+
* @see <a
7+
* href="https://github.com/approvals/ApprovalTests.Java/blob/master/approvaltests/docs/Configuration.md#package-level-settings">ApprovalTests
8+
* Configuration</a>
9+
*/
10+
public class PackageSettings {
11+
public static String ApprovalBaseDirectory = "../approvals";
12+
}

src/test/java/org/codejive/properties/TestProperties.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import java.util.Collections;
1212
import java.util.Iterator;
1313
import java.util.NoSuchElementException;
14+
import org.approvaltests.Approvals;
1415
import org.junit.jupiter.api.Test;
1516

1617
public class TestProperties {
@@ -124,7 +125,7 @@ void testStoreOutputStream() throws IOException, URISyntaxException {
124125
Properties p = Properties.loadProperties(f);
125126
ByteArrayOutputStream os = new ByteArrayOutputStream();
126127
p.store(os);
127-
assertThat(os.toString()).isEqualTo(readAll(f));
128+
Approvals.verify(os.toString());
128129
}
129130

130131
@Test

0 commit comments

Comments
 (0)