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
9
votes
4 answers

is there a scalaTest mechanism similar to TestNg dependsOnMethods annotation

Can I have dependencies between scalaTest specs such that if a test fails, all tests dependent on it are skipped?
user44242
  • 1,168
  • 7
  • 20
9
votes
1 answer

ScalaTest and Maven: getting started

I have a Maven/Java project I've been working on for years, and I wanted to take JavaPosse's advice and start writing my tests in Scala. I've written a few tests following ScalaTest's JUnit4 quick start, and now I want these tests to be executed…
niklassaers
  • 8,480
  • 20
  • 99
  • 146
9
votes
1 answer

Setting up actions for multiple test folders in SBT

In relation to a previous question, I'd like to have multiple test folders for different types of test and be able to execute the tests contained in each folder with a separate SBT action. For example, an action 'test-unit' would run only the tests…
ChucK
  • 2,114
  • 1
  • 18
  • 20
9
votes
1 answer

Setting up multiple test folders in a SBT project

We'd like to set up our SBT project so that we have multiple test folders as opposed to one. So we'd like to see: root src test scala unit functional How would we configure our SBT project file paths to do this?
ChucK
  • 2,114
  • 1
  • 18
  • 20
9
votes
4 answers

How to check an "Either" result in Scala Test?

I am relatively new to Scala Test, and so I consulted the documentation on how to test on Either values. I tried to replicate the instructions like that: import org.scalatest.EitherValues import org.scalatest.flatspec.AnyFlatSpec class EitherTest…
Hannes
  • 5,002
  • 8
  • 31
  • 60
9
votes
1 answer

Scalatest Asynchronous Test Suites vs Eventually and WhenReady (org.scalatest.concurrent)

I'm trying to use scalatest Asynchronous Test Suites, but aside from some restrictions over setting timeout and what not, I don't see what does the test suite actually add. I wonder if anyone versed into asynchronous testing with scalatest could…
MaatDeamon
  • 9,532
  • 9
  • 60
  • 127
9
votes
1 answer

How to use in-memory Derby database for testing with Hive (Scala)

I'm using spark-hive 2.3.0 with Scala 2.11 and setting up a unit test framework. spark-hive comes with TestHiveContext and TestHiveSparkSession which conveniently allow invoking Hive from unit tests without having Hadoop, Spark, or a cluster…
Uncle Long Hair
  • 2,719
  • 3
  • 23
  • 33
9
votes
2 answers

Strange timeout with ScalaTest's Selenium DSL

I'm writing Selenium tests with ScalaTest's Selenium DSL and I'm running into timeouts I can't explain. To make matters more complicated, they only seem to happen some of the time. The problem occurs whenever I access an Element after a page load or…
jqno
  • 15,133
  • 7
  • 57
  • 84
9
votes
1 answer

What is the right way to use ScalaTest's BeforeAndAfterAll trait with sbt and IntelliJ IDEA?

I'm attempting to set up a testing framework for Spark jobs. I'd like to use spark-testing-base's SharedSparkContext trait which relies on ScalaTest's BeforeAndAfterAll trait to manage setup and tear-down. Something about my current environment is…
Cyan
  • 135
  • 1
  • 10
9
votes
5 answers

Functional Tests in Play 2.4.6 when using compile time DI

I'm using Play 2.4.6 with compile time dependency injection and ScalaTest. The controller's constructor has few parameters, and in an ApplicationLoader I create it. Here is the code: class BootstrapLoader extends ApplicationLoader { def…
roterl
  • 1,883
  • 14
  • 24
9
votes
3 answers

ScalaTest: Issues with Singleton Object re-initialization

I am testing a parser I have written in Scala using ScalaTest. The parser handles one file at a time and it has a singleton object like following: class Parser{...} object Resolver {...} The test case I have written is somewhat like this …
thequark
  • 726
  • 1
  • 7
  • 17
9
votes
1 answer

How to run scalatest in parallel with maven surefire plugin?

I'm working on a scala project which use Maven to build and maven-surefire-plugin to run the tests written in scalatest. The tests are like: import org.scalatest.ParallelTestExecution @RunWith(classOf[org.scalatest.junit.JUnitRunner]) class MyTest…
Freewind
  • 193,756
  • 157
  • 432
  • 708
9
votes
1 answer

How to run tests in a class sequentially in ScalaTest?

I have a class which extends org.scalatest.junit.JUnitSuite. This class has a couple of tests. I do not want these tests to run in parallel. I know how simple it is with Specs2 (extend the class with Specification and add a single line sequential…
Sudheer Aedama
  • 2,116
  • 2
  • 21
  • 39
9
votes
1 answer

Is there syntax for adding a clue to ScalaTest matchers?

Is there an idiom for adding a clue to a ScalaTest matcher such that the clue will become part of the assertion failure? I know that I can currently write a ScalaTest assertion like this: withClue("expecting a header row and 3 rows of data") { …
Daryl Odnert
  • 522
  • 3
  • 15
9
votes
2 answers

Group ScalaTest tests and run in order

I would like to partition my tests suites and run them in the way that tests from one partition are not interleaved with tests from some other partition. Is it a way to do this in SBT, ScalaTest?
Jacek L.
  • 1,376
  • 14
  • 19