Skip to content

Instantly share code, notes, and snippets.

@cuipengfei
Last active December 31, 2015 14:39
Show Gist options
  • Select an option

  • Save cuipengfei/8002092 to your computer and use it in GitHub Desktop.

Select an option

Save cuipengfei/8002092 to your computer and use it in GitHub Desktop.
how to set up scala environment for workshop

how to set up scala environment for workshop

1.install scala

2.install sbt

(those two step could take very long)

3.create a build.sbt file in a folder where you want to store your project

4.put this in the build.sbt file:

name := "hello"

version := "1.0"

libraryDependencies += "org.scalatest" %% "scalatest" % "1.9.1" % "test"
 
libraryDependencies += "junit" % "junit" % "4.10" % "test"

5.create folder structure like this (src should be in the same folder as build.sbt is):

src/
  main/
    scala/
  test/
    scala/

6.install the intellij plugin for sbt. (follow this instruction: https://github.com/mpeltonen/sbt-idea)

7.run sbt in the folder where the build.sbt file is

8.run "gen-idea" in sbt

9.go to intellij, open the project that was just created by sbt.

main and test should already be marked as source root and test root by the sbt plugin.

now we should have intellisense available, create your test like this in the /test/scala folder:

package hello

import org.scalatest.FunSuite
import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner

@RunWith(classOf[JUnitRunner])
class HelloWorldTest extends FunSuite {
  test("hello world") {
    assert(1 + 1 === 2)
  }
}

10.go back to sbt, run "test", if you see the test pass, then the set up is done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment