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
30
votes
6 answers

How to disable test suite in ScalaTest

How to disable a test suite, i.e. all tests inside class extending FunSpec? The only solution I'd found is to replace it with ignore in front of each test, but it is boring to do so with the dozens of tests.
lambdas
  • 3,990
  • 2
  • 29
  • 54
29
votes
3 answers

Scalamock 3. Mock overloaded method without parameter

I couldn't find any documentation that explains how to mock overloaded methods that take no arguments in scalamock e.g public boolean isInfoEnabled(Marker marker); public boolean isInfoEnabled(); To mock the function that takes the Marker, one can…
user2715478
  • 1,273
  • 12
  • 17
29
votes
7 answers

Mockito matchers, scala value class and NullPointerException

I'm using mockito with scalatest. I have following problem when using matcher with value class. import org.scalatest.FlatSpec import org.scalatest.mock.MockitoSugar import org.mockito.BDDMockito._ import org.mockito.Matchers.any case class…
Marek Kliś
  • 821
  • 1
  • 8
  • 8
29
votes
3 answers

Testing Actors in Akka

When i run base example for testing actors: class MySpec(_system: ActorSystem) extends TestKit(_system) with ImplicitSender with WordSpec with MustMatchers with BeforeAndAfterAll { I got error: class WordSpec needs to be a trait to be mixed…
lito
  • 989
  • 8
  • 21
29
votes
5 answers

Can't run Scalatest with Gradle

task scalaTest(dependsOn: testClasses) << { description = 'Runs Scalatest suite' ant.taskdef(name: 'scalatest', classname: 'org.scalatest.tools.ScalaTestAntTask', classpath: sourceSets.test.runtimeClasspath.asPath …
Joshua MN
  • 1,486
  • 2
  • 13
  • 26
27
votes
1 answer

How to get ScalaTest to populate test runtimes in the xml report?

We use ScalaTest to run tests and display the results in Jenkins. It works great, but for some reason ScalaTest` does not populate the test runtime. I'm adding test options like this: Tests.Argument("-oD", "-u", "target/test-reports") But the…
Matthew Rathbone
  • 8,144
  • 7
  • 49
  • 79
26
votes
1 answer

scalatest : object scalatest is not a member of package org

EDIT : It works if the file is in src/test/scala/tests/ but not in src/main/scala/mypackage/. Why? I have tried solutions from topics with people having nearly the same issue but none of them work. For details, I have this in build.sbt…
Benjamin
  • 3,350
  • 4
  • 24
  • 49
25
votes
2 answers

String includes many substrings in ScalaTest Matchers

I need to check that one string contains many substrings. The following works string should include ("seven") string should include ("eight") string should include ("nine") but it takes three almost duplicated lines. I'm looking for something…
Michal Kordas
  • 10,475
  • 7
  • 58
  • 103
25
votes
3 answers

How to programmatically ignore/skip tests with ScalaTest?

I am running some tests with ScalaTest which rely on connections to test servers to be present. I currently created my own Spec similar to this: abstract class ServerDependingSpec extends FlatSpec with Matchers { def serverIsAvailable: Boolean =…
rabejens
  • 7,594
  • 11
  • 56
  • 104
23
votes
10 answers

How do I run a scala ScalaTest in IntelliJ idea?

I'm trying to run a scala flatspec test within Intellij IDEA (latest community build, with latest Scala plugin), but I keep getting "Empty test suite" errors. I tried using the normal "run" menu on right click, but it does not work. I also tried…
Matteo Caprari
  • 2,869
  • 4
  • 27
  • 35
23
votes
1 answer

java.lang.IncompatibleClassChangeError: Implementing class with ScalaCheck and ScalaTest

I'm facing a nasty exception when trying to write a test using ScalaCheck and ScalaTest. Here's my dependencies: libraryDependencies ++= Seq( "org.scalatest" %% "scalatest" % "2.2.6" % "test", "org.scalacheck" %% "scalacheck" % "1.13.0" %…
Jeroen Rosenberg
  • 4,552
  • 3
  • 27
  • 39
23
votes
3 answers

How to run a single test in scalatest from maven

I have not found any documentation on how to do this. For JUnit the equivalent would be: mvn -Dtest=org.apache.spark.streaming.InputStreamSuite test
WestCoastProjects
  • 58,982
  • 91
  • 316
  • 560
23
votes
6 answers

Running individual ScalaTest test methods in IntelliJ IDEA

It is possible to run a single, selected JUnit test method in IntelliJ IDEA 12, however this does not seem to be possible with ScalaTest. You can run the whole test class or nothing, but there seems to be no finer grained control for ScalaTest (yet)…
jhegedus
  • 20,244
  • 16
  • 99
  • 167
22
votes
1 answer

What's the difference between shouldBe vs shouldEqual in Scala?

When should I be using shouldBe and when should I be using shouldEqual? port shouldEqual 8000 port shouldBe 8000
jshah
  • 1,599
  • 2
  • 17
  • 38
21
votes
2 answers

Scala testing: What's the status and relationship of SUnit, ScalaTest, ScalaCheck, Specs and ParTest?

Scala provides a choice of different testing frameworks, but I wonder if there are differences in the maturity and stability they have and which distinct features they provide. Is there a specific one which should fit for all kinds of…
soc
  • 27,983
  • 20
  • 111
  • 215