Skip to content

Commit

Permalink
Update hamcrest-library to 2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Nezisi authored and eed3si9n committed Jul 27, 2024
1 parent ffd8405 commit e281f0d
Show file tree
Hide file tree
Showing 16 changed files with 43 additions and 40 deletions.
11 changes: 9 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
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/project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=0.13.9
sbt.version=1.8.3

0 comments on commit e281f0d

Please sign in to comment.