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
0
votes
2 answers

ScalaTest's equivalent of JUnit's suites?

I'm new to Scala. Coming from Java, I'm use to group/bundle my test classes in (JUnit) suites, in a hierarchical matter (suites within suites). I'm looking for an alternative to this in ScalaTest.
Eyal Roth
  • 3,895
  • 6
  • 34
  • 45
0
votes
1 answer

Mockito Stubbing consecutive calls (iterator-style stubbing), exceptions and return void

I'm struggling to get the following test working, basically I want the mocked service call to throw an exception when first called, and work ok on the 2nd invocation. The service method returns nothing (void/Unit), written in scala import…
Tony Murphy
  • 711
  • 9
  • 22
0
votes
1 answer

Unable to find JSONReader for parameterised-typed custom class in test, despite import

I have a custom class as follows object SafeList { def apply[A](x: List[A]): SafeList[A] = if (x == null) EmptyList else HasItems[A](x) } sealed abstract class SafeList[+A] extends Product with Serializable { def get: List[A] } final case…
moncheery
  • 333
  • 4
  • 17
0
votes
1 answer

How do I pass functions into Spark transformations during scalatest?

I am using Flatspec to run a test and keep hitting an error because I pass a function into map. I've encountered this problem a few times, but just found a workaround by just using an anonymous function. That doesn't seem to be possible in this…
AStack41
  • 39
  • 4
0
votes
1 answer

How to programmatically fail scalatest from another thread

As far as I know all assert methods throws exceptions that are handled by the test runner. I'm testing mutlithread application and would like to pass errors from spawned threads to the runner. I understand that runner could not interrupt threads, so…
ayvango
  • 5,867
  • 3
  • 34
  • 73
0
votes
2 answers

Scala test java REST API framework

We have REST API written in Java . I want to write some unit tests in Scala to the REST API. I am looking for a lean, easy to use framework to use (an example or link to example can be helpful) .
igx
  • 4,101
  • 11
  • 43
  • 88
0
votes
2 answers

this as implicit parameter - could not find implicit value for parameter

I've been trying to pass WebBrowser as implicit parameter in a Selenium ScalaTest Spec, but it fails. I have a base superclass for all the tests: abstract class BaseSpec extends FunSpec with WebBrowser with ShouldMatchers { implicit val webDriver:…
Kamil Roman
  • 973
  • 5
  • 15
  • 30
0
votes
1 answer

missing dependency detected during test using scalamock

I'm trying to use scalamock / scalatest and I always have an error during testing My build.sbt name := "name" organization := "org" version := "1.0-SNAPSHOT" scalaVersion := "2.11.7" scalacOptions ++= Seq("-feature",…
Alexandre T
  • 648
  • 2
  • 8
  • 24
0
votes
1 answer

Why Mockito doesn't handle default Scala parameters properly?

I have a code like test("mockito test") { class ToTest { def run(maybe: Option[Int], q: Option[Int] = None): Int = 42 } val mockTest = mock[ToTest] when(mockTest.run(None, None)).thenReturn(98) mockTest.run(None) …
kikulikov
  • 2,512
  • 4
  • 29
  • 45
0
votes
1 answer

Sending auth cookie using WS and ScalaTest

I have a web app which uses a form to login, this returns a session cookie to the user which is used to authorize requests to the rest of the app. I'm having trouble sending this cookie value with my requests. My test harness is below: val…
CalumMcCall
  • 1,665
  • 4
  • 24
  • 46
0
votes
2 answers

How to make JUnit4 lifecycle callbacks work in ScalaTest with JUnitRunner?

According to ScalaTest documentation it's possible to use JUnitRunner to run tests. My assumption was, if it runs with JUnitRunner, its callback methods (i.e. methods marked with @Before or @After annotation should work as well. But apparently my…
wax
  • 2,400
  • 3
  • 19
  • 28
0
votes
1 answer

has ScalaTest an or matcher, testing with PlaySpec Playframework and Scala

I am writing some test in playspec and I want like to write a matcher like this planPromise.trialPeriodDays mustBe (equal (planRequest.trialPeriodDays) or be (None)) What the matcher is trying to do is to identify if the value is an int (previously…
agusgambina
  • 6,229
  • 14
  • 54
  • 94
0
votes
1 answer

ScalaTest option not available under "Run As" Menu in Scala IDE

I have recently switched computers and am trying to get ScalaTest to run in my ScalaIDE again. When I right click on the file in the project explorer, or when I right click on the code in the editor, I can see the "Run As" option in the drop down…
rhamilton
  • 473
  • 3
  • 13
0
votes
1 answer

ExpectMsg error with AkkaTest

I am getting Type mismatch: expected ReaperSpec.this.Register, actual: String where expectMsg(...) is when using AkkaTest with ScalaTest as specified here (http://doc.akka.io/docs/akka/snapshot/scala/testing.html) What am I missing? import…
user1187135
0
votes
0 answers

Problems importing scala for scalatest

I'm new to scala but I'm trying to add some tests to a simple file. The problem is that when I try to import the object into the test I get "error: not found: value" PerfectNumberImperative.scala package perfectImperative package object…
Suavocado
  • 949
  • 12
  • 27