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
7
votes
1 answer

Why does sbt say "bad symbolic reference..." for test with ScalaTest?

I started using ScalaTest with sbt. The build.sbt is as follows: name := "MySpecSample" version := "1.0" libraryDependencies += "org.scalatest" % "scalatest_2.11" % "2.2.0" % "test" scalaVersion := "2.10.3" Initial test code is here. This test…
Kai Sasaki
  • 667
  • 4
  • 13
7
votes
0 answers

Can ScalaTest generate a single HTML report for all subprojects?

I am trying to use ScalaTest (with Scala 2.11.0 and SBT 0.13.x) to generate a single HTML report for a project with many sub projects. To do this, I put the following line in my build.sbt: testOptions in ThisBuild +=…
Martin Snyder
  • 508
  • 3
  • 12
7
votes
3 answers

How to use ScriptEngine in ScalaTest

The following test should pass, but it doesn't class EngineTest extends FunSuite { test("engine should not be null") { val manager: ScriptEngineManager = new ScriptEngineManager val engine: ScriptEngine =…
hkropp
  • 553
  • 2
  • 5
  • 14
7
votes
1 answer

How do I tell ScalaTest to run a class annotated with DoNotDiscover?

ScalaTest 2.0 doesn't automatically run classes that extend Suite but have been annotated with DoNotDiscover. However, it "will run classes annotated with DoNotDiscover if asked to explicitly, it just won't discover them." But how do I explicitly…
KajMagnus
  • 11,308
  • 15
  • 79
  • 127
7
votes
0 answers

Why does scalatest matcher `should not include` not compile with FlatSpec, but work with FunSuite

I am using scala 2.9.3 and scalatest_2.9.3-1.9.2. I am having trouble using the matchers to assert that a string does NOT contain a substring: import org.scalatest.FlatSpec import org.scalatest.matchers.ShouldMatchers._ class Learning extends…
Dilum Ranatunga
  • 13,254
  • 3
  • 41
  • 52
7
votes
1 answer

Canonical Example of how to test Akka Actor using Scala in Play Framework

Having created an Akka actor in Play Framework, I now want to test it. However I immediately hit a problem: The current Play Scala Testing page contains nothing about testing Actors and uses Specs2 for all examples I could find no actor test…
dnh
  • 527
  • 4
  • 15
7
votes
2 answers

Gradle, IntelliJ and ScalaTest plugin: suddenly broken

This is very puzzling. I have a multi module polyglot JVM project built using Gradle. I have a few java modules and a couple scala modules. The scala module uses ScalaTest as the test framework. I set up the Gradle to use the scalatest plugin to run…
Giovanni Botta
  • 9,626
  • 5
  • 51
  • 94
7
votes
2 answers

How to assert that mocked method is never called using ScalaTest and ScalaMock?

I'm using ScalaTest 2.0 and ScalaMock 3.0.1. How do I assert that a method of a mocked trait is called never? import org.scalatest._ import org.scalamock._ import org.scalamock.scalatest.MockFactory class TestSpec extends FlatSpec with MockFactory…
moteutsch
  • 3,741
  • 3
  • 29
  • 35
7
votes
2 answers

ScalaTest - writing custom matchers

I am running into a problem while writing a custom matcher for NodeSeq: private def matchXML(expected: NodeSeq) = new Matcher[NodeSeq] { def apply(left: NodeSeq): MatchResult = MatchResult(left xml_== expected, "XML structure was not the same…
Bober02
  • 15,034
  • 31
  • 92
  • 178
7
votes
6 answers

ScalaTest Run Configuration in Eclipse: cannot find Suite Class

Problem: I cannot setup Run Configurations to run scalatest for the Scalatests in my project. Steps to reproduce: Right click on Scala Suite and click on Run as -> Run configurations.. On the left, I see a configuration template for ScalaTest. I…
RAbraham
  • 5,956
  • 8
  • 45
  • 80
7
votes
2 answers

object scalatest is not a member of package org

I want to write some tests for my toy project in scalatest. As I use sbt I installed scalatest via libraryDependencies += "org.scalatest" %% "scalatest" % "2.0.M5" % "test" in my project root's build.sbt. Then I created test class in…
Vadim Samokhin
  • 3,378
  • 4
  • 40
  • 68
7
votes
2 answers

Mixing scala, maven and java within Eclipse - unit testing

I have a java maven project that I want to unit test with scala. But how can I mix java and scala code within the one Eclipse project since java and scala uses their own compilers. Because of this scala code will not compile in Eclipse since the…
user701254
  • 3,935
  • 7
  • 42
  • 53
7
votes
2 answers

How to test methods based on Salat with ScalaTest

I'm writing a web-app using Play 2, Salat (for mongoDB bindin). I would like to test some methods, in the Lesson Model (for instance test the fact that I retrieve the right lesson by id). The problem is that I don't want to pollute my current DB…
TeaBough
  • 165
  • 6
6
votes
1 answer

BDD in Scalatest: Spec versus WordSpec versus FlatSpec, which should I use?

In Scalatest, I'm a bit unclear as to the advantages and disadvantages of using Spec versus WordSpec. I think the javadoc provide some degree of comparison of WordSpec versus FlatSpec, but I have no idea between Spec and WordSpec. Which would be…
Integrator
  • 519
  • 5
  • 14
6
votes
1 answer

BDD tool for Scala supporting reusable parameterized Gherkin clauses

Is there any BDD tool for Scala supporting reusable parameterized Gherkin clauses? I would like to be able to have the ability to use specs like these: Given number 4 is entered When "+" is pressed And number -1 is entered And "*" is pressed And…
Alexey Tigarev
  • 1,915
  • 1
  • 24
  • 31