-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
As far as I can tell interface works fine.
- Loading branch information
Showing
8 changed files
with
108 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
name := "test-project" | ||
libraryDependencies ++= Seq( | ||
"com.github.sbt.junit" % "jupiter-interface" % JupiterKeys.jupiterVersion.value % Test | ||
) |
1 change: 1 addition & 0 deletions
1
src/plugin/src/sbt-test/basic/interface-demo/project/plugins.sbt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
addSbtPlugin("com.github.sbt.junit" % "sbt-jupiter-interface" % sys.props("project.version")) |
31 changes: 31 additions & 0 deletions
31
src/plugin/src/sbt-test/basic/interface-demo/src/test/java/example/ComparableContract.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package example; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
public interface ComparableContract<T extends Comparable<T>> extends Testable<T> { | ||
|
||
T createSmallerValue(); | ||
|
||
@Test | ||
default void returnsZeroWhenComparedToItself() { | ||
T value = createValue(); | ||
assertEquals(0, value.compareTo(value)); | ||
} | ||
|
||
@Test | ||
default void returnsPositiveNumberWhenComparedToSmallerValue() { | ||
T value = createValue(); | ||
T smallerValue = createSmallerValue(); | ||
assertTrue(value.compareTo(smallerValue) > 0); | ||
} | ||
|
||
@Test | ||
default void returnsNegativeNumberWhenComparedToLargerValue() { | ||
T value = createValue(); | ||
T smallerValue = createSmallerValue(); | ||
assertTrue(smallerValue.compareTo(value) < 0); | ||
} | ||
|
||
} |
31 changes: 31 additions & 0 deletions
31
src/plugin/src/sbt-test/basic/interface-demo/src/test/java/example/EqualsContract.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package example; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
public interface EqualsContract<T> extends Testable<T> { | ||
|
||
T createNotEqualValue(); | ||
|
||
@Test | ||
default void valueEqualsItself() { | ||
T value = createValue(); | ||
assertEquals(value, value); | ||
} | ||
|
||
@Test | ||
default void valueDoesNotEqualNull() { | ||
T value = createValue(); | ||
assertFalse(value.equals(null)); | ||
} | ||
|
||
@Test | ||
default void valueDoesNotEqualDifferentValue() { | ||
T value = createValue(); | ||
T differentValue = createNotEqualValue(); | ||
assertNotEquals(value, differentValue); | ||
assertNotEquals(differentValue, value); | ||
} | ||
|
||
} |
20 changes: 20 additions & 0 deletions
20
src/plugin/src/sbt-test/basic/interface-demo/src/test/java/example/StringTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package example; | ||
|
||
class StringTests implements ComparableContract<String>, EqualsContract<String> { | ||
|
||
@Override | ||
public String createValue() { | ||
return "banana"; | ||
} | ||
|
||
@Override | ||
public String createSmallerValue() { | ||
return "apple"; // 'a' < 'b' in "banana" | ||
} | ||
|
||
@Override | ||
public String createNotEqualValue() { | ||
return "cherry"; | ||
} | ||
|
||
} |
5 changes: 5 additions & 0 deletions
5
src/plugin/src/sbt-test/basic/interface-demo/src/test/java/example/Testable.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package example; | ||
|
||
public interface Testable<T> { | ||
T createValue(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
> test |