Skip to content

Commit

Permalink
Update hamcrest-library to 2.2 (#83)
Browse files Browse the repository at this point in the history
* Update hamcrest-library to 2.2

* Update example projects

* Test on Temurin 17

---------

Co-authored-by: H. Habighorst <h.habighorst@protonmail.com>
  • Loading branch information
eed3si9n and Nezisi authored Jul 27, 2024
1 parent ffd8405 commit bfed0a7
Show file tree
Hide file tree
Showing 25 changed files with 87 additions and 67 deletions.
25 changes: 24 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,14 @@ jobs:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
scala: [2.12.19]
java: [zulu@8]
java: [zulu@8, temurin@17]
exclude:
- scala: 2.12.19
java: zulu@8
os: macos-latest
- scala: 2.12.19
java: temurin@17
os: windows-latest
runs-on: ${{ matrix.os }}
steps:
- name: Ignore line ending differences in git
Expand Down Expand Up @@ -53,6 +60,14 @@ jobs:
java-version: 8
cache: sbt

- name: Setup Java (temurin@17)
if: matrix.java == 'temurin@17'
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 17
cache: sbt

- name: Setup sbt
uses: sbt/setup-sbt@v1

Expand Down Expand Up @@ -109,6 +124,14 @@ jobs:
java-version: 8
cache: sbt

- name: Setup Java (temurin@17)
if: matrix.java == 'temurin@17'
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 17
cache: sbt

- name: Setup sbt
uses: sbt/setup-sbt@v1

Expand Down
19 changes: 17 additions & 2 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,19 @@ import Dependencies.*
ThisBuild / organization := "com.github.sbt.junit"
ThisBuild / scalaVersion := "2.12.19"

lazy val commonSettings: Seq[Setting[_]] = Def.settings(
Compile / javacOptions ++= Seq(
"-encoding", "UTF-8", "-Xlint:all", "-Xlint:-processing", "-source", "1.8", "-target", "1.8"
),
Compile / doc / javacOptions := Seq("-encoding", "UTF-8", "-source", "1.8"),
)

lazy val library = (project in file("src/library"))
.settings(
commonSettings,
name := "jupiter-interface",
autoScalaLibrary := false,
crossPaths := false,
(compile / javacOptions) ++= Seq("-source", "1.8", "-target", "1.8"),
(doc / javacOptions) := Seq("-source", "1.8"),
libraryDependencies ++= Seq(
junitPlatformLauncher,
junitJupiterEngine,
Expand All @@ -49,6 +55,7 @@ lazy val plugin = (project in file("src/plugin"))
.enablePlugins(SbtPlugin)
.dependsOn(library)
.settings(
commonSettings,
name := "sbt-jupiter-interface",
Compile / scalacOptions ++= Seq("-Xlint", "-Xfatal-warnings"),
scriptedBufferLog := false,
Expand Down Expand Up @@ -103,6 +110,14 @@ ThisBuild / scmInfo := Some(
)
)
ThisBuild / githubWorkflowOSes := Seq("ubuntu-latest", "macos-latest", "windows-latest")
ThisBuild / githubWorkflowJavaVersions := List(JavaSpec.zulu("8"), JavaSpec.temurin("17"))
ThisBuild / githubWorkflowBuildMatrixExclusions ++= {
val sv = (ThisBuild / scalaVersion).value
List(
MatrixExclude(Map("scala" -> sv, "java" -> "zulu@8", "os" -> "macos-latest")),
MatrixExclude(Map("scala" -> sv, "java" -> "temurin@17", "os" -> "windows-latest")),
)
}
ThisBuild / githubWorkflowBuild := Seq(WorkflowStep.Sbt(List("test", "scripted")))
ThisBuild / githubWorkflowTargetTags ++= Seq("v*")
ThisBuild / githubWorkflowPublishTargetBranches :=
Expand Down
16 changes: 4 additions & 12 deletions examples/multi-project/build.sbt
Original file line number Diff line number Diff line change
@@ -1,28 +1,20 @@


lazy val commonSettings = Seq(
libraryDependencies ++= Seq(
"com.github.sbt.jupiter" % "jupiter-interface" % JupiterKeys.jupiterVersion.value % Test
)
ThisBuild / scalaVersion := "2.12.19"
ThisBuild / libraryDependencies ++= Seq(
"com.github.sbt.junit" % "jupiter-interface" % JupiterKeys.jupiterVersion.value % Test
)

lazy val moduleA = project.in(file("moduleA"))
.enablePlugins(JvmPlugin)
.settings(commonSettings)
.settings(
name := "moduleA"
)

lazy val moduleB = project.in(file("moduleB"))
.enablePlugins(JvmPlugin)
.settings(commonSettings)
.settings(
name := "moduleB"
)

lazy val root = project.in(file("."))
.settings(commonSettings)
.aggregate(moduleA, moduleB)
.settings(
name := "multi-project"
)
.aggregate(moduleA, moduleB)
2 changes: 1 addition & 1 deletion examples/multi-project/project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=0.13.9
sbt.version=1.10.1
2 changes: 1 addition & 1 deletion examples/multi-project/project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
addSbtPlugin("com.github.sbt.junit" % "sbt-jupiter-interface" % "0.10.0")
addSbtPlugin("com.github.sbt.junit" % "sbt-jupiter-interface" % "0.11.3")
5 changes: 2 additions & 3 deletions examples/simple/build.sbt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@

scalaVersion := "2.12.19"
name := "simple"

libraryDependencies ++= Seq(
"com.github.sbt.junit" % "jupiter-interface" % JupiterKeys.jupiterVersion.value % Test
)
)
2 changes: 1 addition & 1 deletion examples/simple/project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=0.13.9
sbt.version=1.10.1
2 changes: 1 addition & 1 deletion examples/simple/project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
addSbtPlugin("com.github.sbt.junit" % "sbt-jupiter-interface" % "0.10.0")
addSbtPlugin("com.github.sbt.junit" % "sbt-jupiter-interface" % "0.11.3")
4 changes: 2 additions & 2 deletions project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ object Dependencies {
val testInterface = "org.scala-sbt" % "test-interface" % testInterfaceVer
val junitJupiterParams = "org.junit.jupiter" % "junit-jupiter-params" % junitJupiterVer
val junitVintageEngine = "org.junit.vintage" % "junit-vintage-engine" % junitVintageVer
val hamcrestLibrary = "org.hamcrest" % "hamcrest-library" % "1.3"
val mockitoCore = "org.mockito" % "mockito-core" % "2.23.4"
val hamcrestLibrary = "org.hamcrest" % "hamcrest-library" % "2.2"
val mockitoCore = "org.mockito" % "mockito-core" % "4.11.0"
val junit4Interface = "com.github.sbt" % "junit-interface" % "0.13.3"
val junit4 = "junit" % "junit" % "4.13.2"
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

import sbt.testing.AnnotatedFingerprint;

import java.util.Objects;

/**
* A dummy fingerprint implementation used for all discovered tests.
*
Expand All @@ -32,7 +34,6 @@ public class JupiterTestFingerprint implements AnnotatedFingerprint {
*/
@Override
public boolean isModule() {

return false;
}

Expand All @@ -42,13 +43,11 @@ public boolean isModule() {
*/
@Override
public String annotationName() {

return getClass().getName();
}

@Override
public boolean equals(Object obj) {

if (obj instanceof AnnotatedFingerprint) {
AnnotatedFingerprint f = (AnnotatedFingerprint) obj;
if (annotationName().equals(f.annotationName())) {
Expand All @@ -58,4 +57,9 @@ public boolean equals(Object obj) {

return false;
}

@Override
public int hashCode() {
return Objects.hash(this.annotationName(), this.isModule());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
/**
* Writes dispatch events to a file for testing/debugging purposes.
*
* <h3>Example Usage</h3>
* <h2>Example Usage</h2>
* <pre>{@code
* SBT> testOnly -- --trace-dispatch-events
* }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,47 +18,42 @@
*/
package com.github.sbt.junit.jupiter.api;

import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;

import java.io.PrintStream;

import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.not;
import static org.hamcrest.Matchers.startsWith;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.assertThrows;
import static org.mockito.Mockito.mock;

/**
* @author Michael Aichler
*/
public class StreamPairTest {

@Rule
public final ExpectedException thrownException = ExpectedException.none();

@Test
public void shouldThrowExceptionIfOutIsNull() {
Exception thrownException = assertThrows(
NullPointerException.class,
() -> new StreamPair(null, mock(PrintStream.class))
);

thrownException.expect(NullPointerException.class);
thrownException.expectMessage(startsWith("Output stream "));

new StreamPair(null, mock(PrintStream.class));
assertThat(thrownException.getMessage(), startsWith("Output stream "));
}

@Test
public void shouldThrowExceptionIfErrIsNull() {
Exception thrownException = assertThrows(
NullPointerException.class,
() -> new StreamPair(mock(PrintStream.class), null)
);

thrownException.expect(NullPointerException.class);
thrownException.expectMessage(startsWith("Error stream "));

new StreamPair(mock(PrintStream.class), null);
assertThat(thrownException.getMessage(), startsWith("Error stream "));
}

@Test
public void shouldGetTypeOut() {

PrintStream out = mock(PrintStream.class);
PrintStream err = mock(PrintStream.class);

Expand All @@ -69,7 +64,6 @@ public void shouldGetTypeOut() {

@Test
public void shouldGetTypeErr() {

PrintStream out = mock(PrintStream.class);
PrintStream err = mock(PrintStream.class);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import org.junit.Test;

import static org.hamcrest.Matchers.equalTo;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;

/**
* @author Michael Aichler
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.nullValue;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;

/**
* @author Michael Aichler
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

import static java.util.Arrays.asList;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;

/**
* @author Michael Aichler
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

import static java.util.Arrays.asList;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;

/**
* @author Michael Aichler
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

import static com.github.sbt.junit.jupiter.internal.listeners.OutputCapturingTestListener.CapturedOutputStream;
import static org.hamcrest.Matchers.contains;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;

/**
* @author Michael Aichler
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import java.util.regex.Pattern;

import static org.hamcrest.Matchers.equalTo;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;

/**
* Test output formatting of test identifiers.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import org.junit.Test;

import static org.hamcrest.Matchers.contains;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;

public class OptionsParserTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.hasItem;
import static org.hamcrest.Matchers.hasSize;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;

public class Ticket0001Test {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import static org.hamcrest.Matchers.contains;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.hasSize;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;

public class Ticket0003Test {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
import static org.junit.Assert.assertThat;

/**
* Sample test methods for the vintage-engine using {@link Parameterized} runner.
Expand All @@ -18,7 +18,6 @@ public class VintageParameterizedTests {
private final int code;

public VintageParameterizedTests(char alpha, int number) {

this.alpha = alpha;
this.code = number;
}
Expand All @@ -34,7 +33,6 @@ public static Object[][] data() {

@Test
public void testParameters() {

assertThat((int)alpha, equalTo(code));
}
}
2 changes: 1 addition & 1 deletion test-project/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ lazy val jupiter = (project in file("src/jupiter"))
"org.junit.jupiter" % "junit-jupiter-params" % junitJupiterVersion.value % "test"
),
resolvers += Resolver.mavenLocal,
parallelExecution in Test := true
Test / parallelExecution := true
)

lazy val vintage = (project in file("src/vintage"))
Expand Down
Loading

0 comments on commit bfed0a7

Please sign in to comment.