I am very new to Scala / SBT. Is there a test program I use to see I set everything up correctly? -
i trying scala / sbt test things. using notepad++ , command line, no ide.
is there "hello world" tests program? following sbt website example hello world this:
object hi { def main(args: array[string]) = println("hi!") }
does have simple example test can run using sbt? have directories setup correctly still getting hang of using sbt basic tests , simple example greatly.
thanks.
edit:
i had tried using intellij idea ide @ first scala / sbt , scalatest try test example.
this saved in main scala directory.
class hello { def sayhello(name: string) = s"hello, $name!" }
this saved in test scala directory.
import org.scalatest.funsuite class hellotest extends funsuite { test("sayhellomethodworks") { val hello = new hello assert(hello.sayhello("scala") == "hello, scala!") } }
this test runs fine in ide , shows green. how able run same test using command prompt / text editor?
i recommend typesafe activator. there many templates started
run activator new
choose minimal-scal
it creates file build.sbt
name := """hello-world-app""" version := "1.0" scalaversion := "2.11.6" // change test framework if prefer librarydependencies += "org.scalatest" %% "scalatest" % "2.2.4" % "test" // uncomment use akka //librarydependencies += "com.typesafe.akka" %% "akka-actor" % "2.3.11"
and scala file
package com.example object hello { def main(args: array[string]): unit = { println("hello, world!") } }
and test helloworldspec.scala
import org.scalatest._ class hellospec extends flatspec matchers { "hello" should "have tests" in { true should === (true) } }
you can run sbt "~test" continuous run tests, or
sbt test
run test once
Comments
Post a Comment