Scala 3 command line options


I am in the process of updating my teaching code from Scala 2 to Scala 3. In Scala 2 I used to test the students’ code with

scala -i students_code.scala – testing_code.scala -e “”

The students_code.scala contained a single object where the code is added by the students. Testing_code.scala then contains a number of asserts, which bomb if something does not work.

Is there anything equivalent for Scala 3? It seems the commandline options -i and -e are dispensed of in Scala 3.

Thanks a lot!

The new official code runner is scala-cli.

You can use the new tool scala-cli

I tested it with the following setup. In the same directory I have two files:
This is file studentCode.scala

package code

object StudentCode:
  // say this is supposed to check if n is even
  def studentFunction(n: Int): Boolean = 
    ??? // students would write code here

This is file studentCode.test.scala

//> using test.dep org.scalameta::munit::0.7.29

package code

class MyTests extends munit.FunSuite:
  import StudentCode.*

  test("studentFun") {

Then I ran in the same directory:

scala-cli test .

and it gives (with the correct code in studentFunction):

$ scala-cli test .                                                                                                  
Compiling project (Scala 3.3.0, JVM)
Compiled project (Scala 3.3.0, JVM)
Compiling project (test, Scala 3.3.0, JVM)
Compiled project (test, Scala 3.3.0, JVM)
  + studentFun 0.017s