Skip to content

Commit 581d6ba

Browse files
authored
Migrate all tests to JUnit Jupiter (#424)
This change migrates all tests to use JUnit Jupiter, so that is all tests are now annotated with `org.junit.jupiter.api.Test`. In most cases, this is a simple change of imports, with a few exceptions: * Uses of `assertTrue` have been adjusted to allow for the description being the last parameter * `org.hamcrest.AbstractMatcherTest` has been moved to `org.hamcrest.test.AbstractMatcherTest` * Static assertion methods in `AbstractMatcherTest` have been moved to `org.hamcrest.test.MatcherAssertions`
1 parent 246967c commit 581d6ba

File tree

77 files changed

+543
-246
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+543
-246
lines changed

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ these methods will need to be updated. The following methods are affected:
2323
* Javadoc improvements and cleanup ([PR #420](https://github.com/hamcrest/JavaHamcrest/pull/420))
2424
* Optional matchers ([PR #421](https://github.com/hamcrest/JavaHamcrest/pull/421))
2525
* Derive version from git tags ([PR #419](https://github.com/hamcrest/JavaHamcrest/pull/419))
26+
* Migrate all tests to JUnit Jupiter ([PR #424](https://github.com/hamcrest/JavaHamcrest/pull/424))
2627

2728
### Bugfixes
2829

gradle/libs.versions.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# https://docs.gradle.org/current/userguide/platforms.html#sub::toml-dependencies-format
2+
3+
[versions]
4+
junit-jupiter = "5.11.2"
5+
6+
[libraries]
7+
junit-jupiter = { module = "org.junit.jupiter:junit-jupiter", version.ref = "junit-jupiter" }

hamcrest/hamcrest.gradle

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,12 @@ plugins {
55
version = rootProject.version
66

77
dependencies {
8-
testImplementation(group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: '5.10.3') {
9-
transitive = true
10-
}
11-
testImplementation(group: 'org.junit.vintage', name: 'junit-vintage-engine', version: '5.10.3') {
12-
transitive = true
13-
exclude(module: 'hamcrest-core')
14-
}
8+
testImplementation libs.junit.jupiter
9+
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
10+
}
11+
12+
tasks.named("test") {
13+
useJUnitPlatform()
1514
}
1615

1716
jar {

hamcrest/src/test/java/org/hamcrest/AbstractMatcherTest.java

Lines changed: 0 additions & 77 deletions
This file was deleted.

hamcrest/src/test/java/org/hamcrest/BaseDescriptionTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package org.hamcrest;
22

3-
import org.junit.Test;
3+
import org.junit.jupiter.api.Test;
44

5-
import static org.junit.Assert.assertEquals;
5+
import static org.junit.jupiter.api.Assertions.assertEquals;
66

77
public final class BaseDescriptionTest {
88

hamcrest/src/test/java/org/hamcrest/BaseMatcherTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package org.hamcrest;
22

3-
import org.junit.Test;
3+
import org.junit.jupiter.api.Test;
44

5-
import static org.junit.Assert.assertEquals;
5+
import static org.junit.jupiter.api.Assertions.assertEquals;
66

77
public final class BaseMatcherTest {
88

hamcrest/src/test/java/org/hamcrest/CustomMatcherTest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
package org.hamcrest;
22

3-
import org.junit.Test;
3+
import org.junit.jupiter.api.Test;
4+
5+
import static org.hamcrest.test.MatcherAssertions.assertDescription;
46

5-
import static org.hamcrest.AbstractMatcherTest.assertDescription;
67

78
public final class CustomMatcherTest {
89

hamcrest/src/test/java/org/hamcrest/CustomTypeSafeMatcherTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package org.hamcrest;
22

3-
import org.junit.Test;
3+
import org.junit.jupiter.api.Test;
44

5-
import static org.hamcrest.AbstractMatcherTest.*;
5+
import static org.hamcrest.test.MatcherAssertions.*;
66

77
public final class CustomTypeSafeMatcherTest {
88

hamcrest/src/test/java/org/hamcrest/FeatureMatcherTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package org.hamcrest;
22

33
import org.hamcrest.core.IsEqual;
4-
import org.junit.Test;
4+
import org.junit.jupiter.api.Test;
55

6-
import static org.hamcrest.AbstractMatcherTest.*;
7-
import static org.junit.Assert.assertEquals;
6+
import static org.hamcrest.test.MatcherAssertions.*;
7+
import static org.junit.jupiter.api.Assertions.assertEquals;
88

99
public final class FeatureMatcherTest {
1010

hamcrest/src/test/java/org/hamcrest/MatcherAssertTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package org.hamcrest;
22

3-
import org.junit.Test;
3+
import org.junit.jupiter.api.Test;
44

55
import static org.hamcrest.MatcherAssert.assertThat;
66
import static org.hamcrest.core.IsEqual.equalTo;
7-
import static org.junit.Assert.*;
7+
import static org.junit.jupiter.api.Assertions.*;
88

99
public final class MatcherAssertTest {
1010

0 commit comments

Comments
 (0)