-
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added JUnit5 variations of the testcases
- Loading branch information
1 parent
ac05b42
commit a8289fc
Showing
110 changed files
with
2,406 additions
and
0 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,22 @@ | ||
import org.gradle.api.tasks.testing.logging.TestExceptionFormat | ||
|
||
plugins { | ||
kotlin("jvm") version "1.9.0" | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
testImplementation("org.junit.jupiter:junit-jupiter-api:5.10.0") | ||
testImplementation("org.junit.jupiter:junit-jupiter-engine:5.10.0") | ||
} | ||
|
||
tasks.withType<Test> { | ||
useJUnitPlatform() | ||
testLogging { | ||
exceptionFormat = TestExceptionFormat.FULL | ||
events("passed", "failed", "skipped") | ||
} | ||
} |
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,61 @@ | ||
{ | ||
"version": 2, | ||
"status": "fail", | ||
"message": "", | ||
"tests": [ | ||
{ | ||
"name": "divisible by 400 but not by 125", | ||
"status": "fail", | ||
"message": "expected: <true> but was: <false>", | ||
"output": "" | ||
}, | ||
{ | ||
"name": "divisible by 100, not divisible by 400", | ||
"status": "fail", | ||
"message": "expected: <false> but was: <true>", | ||
"output": "" | ||
}, | ||
{ | ||
"name": "divisible by 400", | ||
"status": "fail", | ||
"message": "expected: <true> but was: <false>", | ||
"output": "" | ||
}, | ||
{ | ||
"name": "not divisible by 4", | ||
"status": "fail", | ||
"message": "expected: <false> but was: <true>", | ||
"output": "" | ||
}, | ||
{ | ||
"name": "divisible by 2, not divisible by 4", | ||
"status": "fail", | ||
"message": "expected: <false> but was: <true>", | ||
"output": "" | ||
}, | ||
{ | ||
"name": "divisible by 4 and 5", | ||
"status": "fail", | ||
"message": "expected: <true> but was: <false>", | ||
"output": "" | ||
}, | ||
{ | ||
"name": "divisible by 4, not divisible by 100", | ||
"status": "fail", | ||
"message": "expected: <true> but was: <false>", | ||
"output": "" | ||
}, | ||
{ | ||
"name": "divisible by 200, not divisible by 400", | ||
"status": "fail", | ||
"message": "expected: <false> but was: <true>", | ||
"output": "" | ||
}, | ||
{ | ||
"name": "divisible by 100 but not by 3", | ||
"status": "fail", | ||
"message": "expected: <false> but was: <true>", | ||
"output": "" | ||
} | ||
] | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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 @@ | ||
data class Year(private val year: Int) { | ||
val isLeap: Boolean by lazy { ! (divisibleBy(4) && (divisibleBy(400) || !divisibleBy(100))) } | ||
|
||
private fun divisibleBy(i: Int) = year % i == 0 | ||
} |
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,45 @@ | ||
import org.junit.jupiter.api.Disabled | ||
import org.junit.jupiter.api.Test | ||
import org.junit.jupiter.api.Assertions.assertFalse | ||
import org.junit.jupiter.api.Assertions.assertTrue | ||
|
||
class LeapTest { | ||
@Test | ||
fun `not divisible by 4`() = assertYearIsCommon(2015) | ||
|
||
@Disabled | ||
@Test | ||
fun `divisible by 2, not divisible by 4`() = assertYearIsCommon(1970) | ||
|
||
@Disabled | ||
@Test | ||
fun `divisible by 4, not divisible by 100`() = assertYearIsLeap(1996) | ||
|
||
@Disabled | ||
@Test | ||
fun `divisible by 4 and 5`() = assertYearIsLeap(1960) | ||
|
||
@Disabled | ||
@Test | ||
fun `divisible by 100, not divisible by 400`() = assertYearIsCommon(2100) | ||
|
||
@Disabled | ||
@Test | ||
fun `divisible by 100 but not by 3`() = assertYearIsCommon(1900) | ||
|
||
@Disabled | ||
@Test | ||
fun `divisible by 400`() = assertYearIsLeap(2000) | ||
|
||
@Disabled | ||
@Test | ||
fun `divisible by 400 but not by 125`() = assertYearIsLeap(2400) | ||
|
||
@Disabled | ||
@Test | ||
fun `divisible by 200, not divisible by 400`() = assertYearIsCommon(1800) | ||
} | ||
|
||
private fun assertYearIsLeap(year: Int) = assertTrue(Year(year).isLeap) | ||
|
||
private fun assertYearIsCommon(year: Int) = assertFalse(Year(year).isLeap) |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,22 @@ | ||
import org.gradle.api.tasks.testing.logging.TestExceptionFormat | ||
|
||
plugins { | ||
kotlin("jvm") version "1.9.0" | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
testImplementation("org.junit.jupiter:junit-jupiter-api:5.10.0") | ||
testImplementation("org.junit.jupiter:junit-jupiter-engine:5.10.0") | ||
} | ||
|
||
tasks.withType<Test> { | ||
useJUnitPlatform() | ||
testLogging { | ||
exceptionFormat = TestExceptionFormat.FULL | ||
events("passed", "failed", "skipped") | ||
} | ||
} |
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,6 @@ | ||
{ | ||
"version": 2, | ||
"status": "error", | ||
"message": "[ERROR] src/test/kotlin/LeapTest.kt:[43,54] Unresolved reference: Year\n[ERROR] src/test/kotlin/LeapTest.kt:[45,57] Unresolved reference: Year", | ||
"tests": [] | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
45 changes: 45 additions & 0 deletions
45
tests/example-empty-file-junit5/src/test/kotlin/LeapTest.kt
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,45 @@ | ||
import org.junit.jupiter.api.Disabled | ||
import org.junit.jupiter.api.Test | ||
import org.junit.jupiter.api.Assertions.assertFalse | ||
import org.junit.jupiter.api.Assertions.assertTrue | ||
|
||
class LeapTest { | ||
@Test | ||
fun `not divisible by 4`() = assertYearIsCommon(2015) | ||
|
||
@Disabled | ||
@Test | ||
fun `divisible by 2, not divisible by 4`() = assertYearIsCommon(1970) | ||
|
||
@Disabled | ||
@Test | ||
fun `divisible by 4, not divisible by 100`() = assertYearIsLeap(1996) | ||
|
||
@Disabled | ||
@Test | ||
fun `divisible by 4 and 5`() = assertYearIsLeap(1960) | ||
|
||
@Disabled | ||
@Test | ||
fun `divisible by 100, not divisible by 400`() = assertYearIsCommon(2100) | ||
|
||
@Disabled | ||
@Test | ||
fun `divisible by 100 but not by 3`() = assertYearIsCommon(1900) | ||
|
||
@Disabled | ||
@Test | ||
fun `divisible by 400`() = assertYearIsLeap(2000) | ||
|
||
@Disabled | ||
@Test | ||
fun `divisible by 400 but not by 125`() = assertYearIsLeap(2400) | ||
|
||
@Disabled | ||
@Test | ||
fun `divisible by 200, not divisible by 400`() = assertYearIsCommon(1800) | ||
} | ||
|
||
private fun assertYearIsLeap(year: Int) = assertTrue(Year(year).isLeap) | ||
|
||
private fun assertYearIsCommon(year: Int) = assertFalse(Year(year).isLeap) |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Empty file.
File renamed without changes.
File renamed without changes.
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,23 @@ | ||
{ | ||
"blurb": "Given a year, report if it is a leap year.", | ||
"authors": ["sdavids13"], | ||
"contributors": [ | ||
"dector", | ||
"eparovyshnaya", | ||
"jtigger", | ||
"lihofm", | ||
"mdowds", | ||
"nithia", | ||
"sjwarner-bp", | ||
"SleeplessByte", | ||
"stkent", | ||
"uzilan" | ||
], | ||
"files": { | ||
"solution": ["src/main/kotlin/Leap.kt"], | ||
"test": ["src/test/kotlin/LeapTest.kt"], | ||
"example": [".meta/src/reference/kotlin/Leap.kt"] | ||
}, | ||
"source": "JavaRanch Cattle Drive, exercise 3", | ||
"source_url": "http://www.javaranch.com/leap.jsp" | ||
} |
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 @@ | ||
1.6.0 |
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,22 @@ | ||
import org.gradle.api.tasks.testing.logging.TestExceptionFormat | ||
|
||
plugins { | ||
kotlin("jvm") version "1.9.0" | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
testImplementation("org.junit.jupiter:junit-jupiter-api:5.10.0") | ||
testImplementation("org.junit.jupiter:junit-jupiter-engine:5.10.0") | ||
} | ||
|
||
tasks.withType<Test> { | ||
useJUnitPlatform() | ||
testLogging { | ||
exceptionFormat = TestExceptionFormat.FULL | ||
events("passed", "failed", "skipped") | ||
} | ||
} |
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,61 @@ | ||
{ | ||
"version": 2, | ||
"status": "fail", | ||
"message": "", | ||
"tests": [ | ||
{ | ||
"name": "divisible by 400 but not by 125", | ||
"status": "fail", | ||
"message": "expected: <true> but was: <false>", | ||
"output": "" | ||
}, | ||
{ | ||
"name": "divisible by 100, not divisible by 400", | ||
"status": "pass", | ||
"message": "", | ||
"output": "" | ||
}, | ||
{ | ||
"name": "divisible by 400", | ||
"status": "fail", | ||
"message": "expected: <true> but was: <false>", | ||
"output": "" | ||
}, | ||
{ | ||
"name": "not divisible by 4", | ||
"status": "pass", | ||
"message": "", | ||
"output": "" | ||
}, | ||
{ | ||
"name": "divisible by 2, not divisible by 4", | ||
"status": "pass", | ||
"message": "", | ||
"output": "" | ||
}, | ||
{ | ||
"name": "divisible by 4 and 5", | ||
"status": "pass", | ||
"message": "", | ||
"output": "" | ||
}, | ||
{ | ||
"name": "divisible by 4, not divisible by 100", | ||
"status": "pass", | ||
"message": "", | ||
"output": "" | ||
}, | ||
{ | ||
"name": "divisible by 200, not divisible by 400", | ||
"status": "pass", | ||
"message": "", | ||
"output": "" | ||
}, | ||
{ | ||
"name": "divisible by 100 but not by 3", | ||
"status": "pass", | ||
"message": "", | ||
"output": "" | ||
} | ||
] | ||
} |
Binary file not shown.
7 changes: 7 additions & 0 deletions
7
tests/example-partial-fail-junit5/gradle/wrapper/gradle-wrapper.properties
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,7 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip | ||
networkTimeout=10000 | ||
validateDistributionUrl=true | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
Oops, something went wrong.