Questions tagged [scalatest]

The Scala testing framework

ScalaTest is a testing framework for Scala, which can test either Scala or Java code.

It supports a number of different testing styles, as JUnit, TestNG, FunSuite (For test-driven development), Spec (for behaviour driven development) and FeatureSpec (for functional, integration, or acceptance testing).

1597 questions
10
votes
1 answer

Cannot Find GeneratorDrivenPropertyChecks Trait

I have these test dependencies defined / Test Dependencies lazy val wiremock = "com.github.tomakehurst" % "wiremock-jre8" % "2.25.1" lazy val playTest = "com.typesafe.play" %% "play-test" …
Mojo
  • 1,152
  • 1
  • 8
  • 16
10
votes
2 answers

can you test nested functions in scala?

Is there any way to test a nested function (ideally with ScalaTest)? For example, is there a way to test g() in the below code: def f() = { def g() = "a string!" g() + "– says g" }
Aaron Yodaiken
  • 19,163
  • 32
  • 103
  • 184
10
votes
2 answers

Injecting PlaySlick database connection in ScalaTest

I have the following DAO that connects to a database using PlaySlick. The class has a method read that I need to test with ScalaTest. My problem is that I don't know how to mock DatabaseConfigProvider to inject it in the UsersDAO class and test the…
ps0604
  • 1,227
  • 23
  • 133
  • 330
10
votes
1 answer

Scalatest ExecutionContext

I would like to know which ExecutionContext I should use (and why) on scalatest % 2.2.6 to run my futures and mock's futures. class Foo { def foo: Future[String] = Future.sucessful("B") } class Bar(foo: Foo) { def bar: Future[String] =…
Henrique Goulart
  • 1,815
  • 2
  • 22
  • 32
10
votes
1 answer

IntelliJ: breakpoints in Scala tests won't get hit

I'm trying to debug a test in my Scala project. IntelliJ runs the tests successfully, however the breakpoints in the tests never get hit. The breakpoints inside the tested classes do get hit during the test, so I assume the problem is with…
JeB
  • 11,653
  • 10
  • 58
  • 87
10
votes
5 answers

Why does Spark fail with "Failed to get broadcast_0_piece0 of broadcast_0" in local mode?

I'm running this snippet to sort an RDD of points, ordering the RDD and taking the K-nearest points from a given point: def getKNN(sparkContext:SparkContext, k:Int, point2:Array[Double], pointsRDD:RDD[Array[Double]]): RDD[Array[Double]] = { val…
Saulo Ricci
  • 776
  • 1
  • 8
  • 27
10
votes
1 answer

Cannot Resolve Symbol "Scalatest"

I am trying to use scalatest, but Intellij cannot recognize: import org.scalatest._ Here is my build.sbt file, located in the same directory as my scalatest.jar file. scalaVersion := "2.11.2" libraryDependencies += "org.scalatest" %…
nietsnegttiw
  • 371
  • 1
  • 5
  • 16
10
votes
1 answer

How do I test an Akka actor that sends a message to another actor?

I'm using ScalaTest with the Akka TestKit to write unit and integration tests for an actor I've coded to simply send a message to another actor without mutating any internal state. Take this for example: class MyActor extends Actor { val…
nmurthy
  • 1,337
  • 1
  • 12
  • 24
10
votes
2 answers

How to show difference between what is given and expected in ScalaTest?

If you match lists or maps or any other complex structures it's useful to see the difference between what is given and what expected. For example: Map("a" -> 1, "b" -> 2, "c" -> 3) should equal Map("a" -> 1, "b" -> 5, "c" -> 3) // ScalaTest…
Andrew
  • 8,330
  • 11
  • 45
  • 78
10
votes
1 answer

Advantages of using ScalaFutures from ScalaTest vs. Await.result

I recently had a discussions with colleagues over the use or whenReady or .futureValue from ScalaFutures in ScalaTest versus Await.result in tests. Besides the readability, consistency in configuration (timeouts) and result scoping when using…
jgagnon1
  • 135
  • 8
10
votes
1 answer

specs/scalatest interaction issue in Play app

I am having a problem I really can't explain... It is in isolation in the project at https://github.com/betehess/play-scalatest. When I run test, sbt gets stuck for a while and then throws this exception: > test [error] Uncaught exception when…
betehess
  • 839
  • 4
  • 19
10
votes
1 answer

Run a SBT task with arguments from command line

I want to hava a SBT task which takes comma-separated list of test classes given by their fully qualified name as input from command line. Now that I run the task with hard-coded value but I want to get it from command line. Can someone help me in…
Sarath
  • 1,438
  • 4
  • 24
  • 40
10
votes
2 answers

how to add scala-test support to intellij

How do I install scala-test with intellij. The video on the intellij website shows them adding a library dependency with scala-test showing up on the list. I don't have that however as I'll need to install scala-test somehow first. The quickstart…
MonkeyBonkey
  • 46,433
  • 78
  • 254
  • 460
10
votes
2 answers

How to test that Akka actor was created in Scala

I'm trying to write a test that will verify that my actor below is creating a heartBeatExpireWorker and a heartBeatAccepter, but I have no idea how to do it. First I was thinking I could use Mockhito mock or a spy in place of context and then…
HappyCoder86
  • 2,267
  • 3
  • 25
  • 40
10
votes
1 answer

passing futures to whenReady fails

I'm trying to write a spec for something using futures, and I'm not sure how I'm supposed to use the Futures trait. I have to pass whenReady a FutureConcept, but I can't find how I should construct one from a Future. The documentation reads: To…
Martijn
  • 11,964
  • 12
  • 50
  • 96