Skip to content

Commit 574edad

Browse files
authored
Adding test in Scala in app module (#12)
Unit testing in Scala instead of Java, needs new Scala Android Plugin version and Gradle 8.13
1 parent d01560c commit 574edad

File tree

5 files changed

+32
-34
lines changed

5 files changed

+32
-34
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ This is the Scala project you get if:
2020

2121
## Notes
2222

23-
### Why Scala 3.7.0-RC2?
23+
### Why Scala 3.7.0?
2424

2525
Because is the first Scala version shipping https://github.com/scala/scala3/pull/22632.
2626
The emitted Scala code is more compatible with Android ART.

app/src/test/java/com/example/scala_3_android_java/ExampleUnitTest.java

Lines changed: 0 additions & 31 deletions
This file was deleted.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package com.example.scala_3_android_java
2+
3+
import com.example.core.Foo
4+
import org.junit.Test
5+
import org.junit.Assert.*
6+
7+
import scala.jdk.javaapi.OptionConverters
8+
9+
/**
10+
* Example local unit test, which will execute on the development machine (host).
11+
*
12+
* See [testing documentation](http://d.android.com/tools/testing).
13+
*/
14+
class ScalaUnitTest {
15+
16+
@Test
17+
def addition_isCorrect(): Unit = {
18+
assertEquals(4, 2 + 2)
19+
}
20+
21+
@Test def integer_fromScalaCore(): Unit = {
22+
assertEquals(42, Foo.bar)
23+
}
24+
25+
@Test def converted_option_fromScalaCore(): Unit = {
26+
assertEquals(42, OptionConverters.toJava(Foo.option).get)
27+
}
28+
29+
}

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ material = "1.12.0"
88
constraintlayout = "2.2.1"
99
lifecycleLivedataKtx = "2.8.7"
1010
lifecycleViewmodelKtx = "2.8.7"
11-
scalaAndroidPlugin = "24.1019.1546"
11+
scalaAndroidPlugin = "25.0412.2039"
1212
scala3Library_x = "3.7.0-RC2"
1313

1414
[libraries]
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#Sun Mar 09 20:26:37 CET 2025
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
4-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip
4+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
55
zipStoreBase=GRADLE_USER_HOME
66
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)