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

How can I mock the singleton object (scala 2.7.11)?

I want to mock the singleton object? It seems that it's impossible in scalamock-3 I found that easyMock and powerMock can mock the singleton object (from https://github.com/fabura/scala-MockStaticObjects) However, I cant get this work? Any ideas?
0
votes
1 answer

Scala: Implicit ordering issue

I'm working exercises from the book Learning Scala and one question asks: A popular use for implicit parameters is for a default setting that works most of the time but may be overridden in special cases. Assume you are writing a sorting…
Abhijit Sarkar
  • 21,927
  • 20
  • 110
  • 219
0
votes
1 answer

Easy way to get result of a test spec

I think I'm missing something obvious, is there a way to easily receive result of test run? I'm running scalatest with simple run(new my.TestClass) Is there any way to get the result of the test back? Or some way to run code after test failure? Only…
cvakiitho
  • 1,377
  • 13
  • 27
0
votes
1 answer

Sequential test suite error with Scalatest in Play 2.2, Slick 3 and HikariCP pool db

Now I update my application to Play 2.4 and Slick 3. To test Application I use Scalatest and several test suites. The issue in next. First test suite is performed correctly, but the second one crash with next error: Testing started at 6:29…
0
votes
1 answer

Scala: Ordering[Int].lt invocation fails for reflective method call

I'm playing with Scala reflection and ScalaTest. I've a method defined as follows in an object Ch2: def isSorted[A](as: Array[A], ordered: (A, A) => Boolean): Boolean The following test fails as described in the comment: "Method isSorted" should…
Abhijit Sarkar
  • 21,927
  • 20
  • 110
  • 219
0
votes
2 answers

ScalaTest in Intellij Idea halts after failed test

I'm writing ScalaTest code in Intellij Idea 14, and I would like to see the output in Intellij. I currently have 2 tests, of which I expect one to fail, the other to succeed. When I run the tests in Intellij, as soon as the failing one is executed,…
danielvdende
  • 690
  • 9
  • 23
0
votes
1 answer

Could not find artifact org.scalatest:maven-scalatest-plugin:jar:1.0

I'm trying to run some scala tests (FlatSpec style) using maven, however, when I run mvn test I get the following error. Could not find artifact org.scalatest:maven-scalatest-plugin:jar:1.0 I'm following the instructions from…
Jane Wayne
  • 8,205
  • 17
  • 75
  • 120
0
votes
2 answers

Is there a method of ScalaTest for initialisation before a feature? (featureSpec suit)

I just started to use ScalaTest and I want to do some initialisation before my feature test. my test looks something like this: class InvoiceTests extends FeatureSpec with GivenWhenThen with ShouldMatchers { feature("Traffic Light Test")…
JohnBigs
  • 2,691
  • 3
  • 31
  • 61
0
votes
1 answer

Waiting for a Future to complete before making assertions

I have a Scala Play application and one of the controllers fires a Future which does some logging. I have a simple call back function which executes when the Future completes. I have written a test to check whether this logging happens. The rough…
user3248346
0
votes
1 answer

Writing ScalaTest for ReactiveMongoApi in Playframework 2.4?

I am trying to start writing test for mongodb in my play application. It seems that I can not get it working because the connection is shutdown before the save is executed. Here are the results [info] UserDaoMongoSpec: [info] UserDao [info] -…
agusgambina
  • 6,229
  • 14
  • 54
  • 94
0
votes
0 answers

facing error in ScalaTest

i am trying to run a simple ScalaTest app to understand the scala testing my code is: package org.scalatest.examples.flatspec import org.scalatest.FlatSpec import collection.mutable.Stack import org.scalatest._ class ExampleSpec extends…
Tahir
  • 39
  • 5
0
votes
1 answer

Test with BeforeAndAfter, table drop in after, table still there

I'm a trying to do a little integration-test in tdd for an idea I've been tinkering with. I'm not new to TDD, but not an expert either. And I've started with it in ScalaTest just yesterday, so here I am. This is what works: class BookTest extends…
user4063815
0
votes
1 answer

Integration-Test of Future results leads to passing tests that are obviously wrong

Consider the following test: class BookTest extends FlatSpec with Matchers with ScalaFutures with BeforeAndAfter { implicit val defaultPatience = PatienceConfig(timeout = Span(5, Seconds), interval = Span(500, Millis)) val db =…
user4063815
0
votes
0 answers

PlaySlick running multiple specs2 testcases throws an error for the later one of MYSQL connection rejected

I have written a few testcases with specs2 in play framework using Slick with MySQL database connection. A Database Connection rejected error is thrown for the later testcase, hence results in failure. the error thrown is Task…
Sumit Paliwal
  • 385
  • 1
  • 3
  • 14
0
votes
2 answers

Scala: Mocking an enclosed object

I'm trying to write a unit test for object A, which uses some methods from another object B. How do I override B's methods? A.scala import somePackage.B object A { // This is to be tested def fun1(str: String) = { val str2 = processStr(str)…
Sahil Sareen
  • 1,813
  • 3
  • 25
  • 40