Skip to content

Commit

Permalink
Add scripted test for simple test and mixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Antonio Lopez Marin authored and Antonio Lopez Marin committed Jul 9, 2018
1 parent 1b05cc8 commit 0974be8
Show file tree
Hide file tree
Showing 11 changed files with 81 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/sbt-test/kotlin/basic-tests/build.sbt
@@ -0,0 +1,5 @@
kotlinLib("stdlib")

libraryDependencies ++= Seq(
"com.novocode" % "junit-interface" % "0.11" % Test
)
9 changes: 9 additions & 0 deletions src/sbt-test/kotlin/basic-tests/project/plugins.sbt
@@ -0,0 +1,9 @@
{
val ver = System.getProperty("plugin.version")
if (ver == null)
throw new RuntimeException("""
|The system property 'plugin.version' is not defined.
|Specify this property using scriptedLaunchOpts -Dplugin.version."""
.stripMargin)
else addSbtPlugin("com.hanhuy.sbt" % "kotlin-plugin" % ver)
}
6 changes: 6 additions & 0 deletions src/sbt-test/kotlin/basic-tests/src/main/kotlin/simple.kt
@@ -0,0 +1,6 @@
package demo

fun main(args: Array<String>) {
println("Hello, world!")
}

11 changes: 11 additions & 0 deletions src/sbt-test/kotlin/basic-tests/src/test/kotlin/SimpleTest.kt
@@ -0,0 +1,11 @@
import org.junit.Test
import junit.framework.TestCase.assertEquals

class SimpleTest {

@Test
fun `should works`() {
assertEquals(4, 2 + 2)
}

}
3 changes: 3 additions & 0 deletions src/sbt-test/kotlin/basic-tests/test
@@ -0,0 +1,3 @@
> compile
> test
> "test-only *SimpleTest"
5 changes: 5 additions & 0 deletions src/sbt-test/kotlin/mixed-tests/build.sbt
@@ -0,0 +1,5 @@
kotlinLib("stdlib")

libraryDependencies ++= Seq(
"com.novocode" % "junit-interface" % "0.11" % Test
)
9 changes: 9 additions & 0 deletions src/sbt-test/kotlin/mixed-tests/project/plugins.sbt
@@ -0,0 +1,9 @@
{
val ver = System.getProperty("plugin.version")
if (ver == null)
throw new RuntimeException("""
|The system property 'plugin.version' is not defined.
|Specify this property using scriptedLaunchOpts -Dplugin.version."""
.stripMargin)
else addSbtPlugin("com.hanhuy.sbt" % "kotlin-plugin" % ver)
}
@@ -0,0 +1,9 @@
package demo;

public class JavaCalculator {

public int sum(int a, int b) {
return a + b;
}

}
7 changes: 7 additions & 0 deletions src/sbt-test/kotlin/mixed-tests/src/main/kotlin/Calculator.kt
@@ -0,0 +1,7 @@
package demo

class Calculator(private val calculator: JavaCalculator) {

fun sum(a: Int, b: Int): Int = calculator.sum(a, b)

}
14 changes: 14 additions & 0 deletions src/sbt-test/kotlin/mixed-tests/src/test/kotlin/MixedTest.kt
@@ -0,0 +1,14 @@
import org.junit.Test
import junit.framework.TestCase.assertEquals
import demo.Calculator
import demo.JavaCalculator

class MixedTest {

@Test
fun `should sum 2 plus 2`() {
val calculator = Calculator(JavaCalculator())
assertEquals(4, calculator.sum(2, 2))
}

}
3 changes: 3 additions & 0 deletions src/sbt-test/kotlin/mixed-tests/test
@@ -0,0 +1,3 @@
> compile
> test
> "test-only *MixedTest"

0 comments on commit 0974be8

Please sign in to comment.