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

Override the tags for a test in ScalaTest

I'd like to apply the DRY principle to my ScalaTest test definitions. Specifically, I'd like to define an abstract test class that defines a bunch of tests. All of the tests call some function with parameters indicating the conditions to be…
John Arrowwood
  • 2,370
  • 2
  • 21
  • 32
0
votes
1 answer

Play 2.5.3 - Running Scalatest on console, getting java.lang.NoClassDefFoundError: Could not initialize class play.api.Play$

I get below error when I run the unit tests using sbt console twice or more. I do not get any error when I run for the first time. If I get out from Sbt (Ctrl+D) and go back to Sbt, there is no issue with running the tests for the first time.Using…
ecamur
  • 99
  • 1
  • 4
0
votes
1 answer

Scalatest to check if a map contains values form a list

A method is returning a Map of tuples, for this test to pass I need to check that the map contains n number of keys and that the key values match. I started with a result.foreach(f=> f._ == "value")) but I can't seem to check the other values in the…
null
  • 3,469
  • 7
  • 41
  • 90
0
votes
2 answers

spark map operation changes schema

This has me confused. I'm using "spark-testing-base_2.11" % "2.0.0_0.5.0" for the test. Can anyone explain why the map function changes the schema if using a Dataset, but works if I use the RDD? Any insights greatly appreciated. import…
Richard
  • 1
  • 1
0
votes
0 answers

scala test: verify using functions as parameters

I am trying to use verify on a mocked object's method, where it receives two parameters, one of them a String and the other one a function. So basically in my test i have: verify(mockedObj).someMethod(aString, theFunction _) theFunction is defined…
9uzman7
  • 409
  • 8
  • 19
0
votes
2 answers

Play/Scala injecting Object into controller for testing

I saw this thread Play/Scala injecting controller into test I have similar issue like this, but my issue is how to inject the object for testing the controller. Controller @Singleton class ExampleCtrl @Inject() (dao: TestDAO) extends Controller…
Mexud
  • 1
  • 3
0
votes
1 answer

Scala Test JAR file with argument

I'm using spark 2.0, sbt 0.13 and Scala Test 3.0, I would like to know if how can I pass arguments from command like to test JAR file like the way I do the main JAR file. For e.g, spark-submit my-test-file.jar args1 args2, and test cases in my test…
Gia Duong Duc Minh
  • 1,319
  • 5
  • 15
  • 30
0
votes
1 answer

How to use org.scalatest.Suite

I'm trying to use scalatest suite using intellij idea like this : class SampleTest extends org.scalatest.Suite { def myTest() { assert(true) } } (new SampleTest).execute() I have added scalactic_2.11 and scalactic_2.11 to my pom…
abshar
  • 467
  • 1
  • 4
  • 8
0
votes
2 answers

Integration tests on a server on Play Framework 2.5

I am building a REST service on top of Play Framework 2.5 I want to create an integration test to test my service as if accessed by an external client. Using the documentation here -- I mixed OneServerPerSuite in my testing class and overrode 'app'…
Barak BN
  • 442
  • 6
  • 14
0
votes
2 answers

How to detect if a method is called by unit test?

How do I detect if a method is called by unit test in ScalaTest? Edit: sorry, I was expressing wrongly the thing I wanted. I have a code block in a method which takes very long to finish (I cannot mock it) and it does not affect any logic. I want to…
mmdc
  • 1,677
  • 3
  • 20
  • 32
0
votes
1 answer

can i validate 2 conditions inside scalatest eventually block?

I tried to validate 2 conditions inside eventually block... something like this eventually(timeout(Span(26, Seconds)), interval(Span(2, Seconds))) { response = executeSomeFunction response should be = (true) if (response) { …
nname
  • 59
  • 1
  • 9
0
votes
0 answers

Can't get Guice Injector Instance play 2.5 scalatest

We are using scalatestplus-play 1.5.1 version. Here is the code snippet for BaseTestClass : trait GuiceMock extends Suite with OneAppPerTest with BeforeAndAfterAll { def injector(): Injector = { app.injector } override def…
hackmabrain
  • 457
  • 1
  • 6
  • 21
0
votes
1 answer

ScalaMock Inheritied Trait Function of Object ScalaTest

I am attempting to test a function, however the function that I am testing makes a call to the traits function which I would like to stub. I can't seem to stub this function using ScalaMock, as I am unable to mock the object. trait[A<:CommonReturn]…
Adam Pitt
  • 128
  • 10
0
votes
1 answer

Scalatest + maven

I am trying to use scalatest to test a class. This is the test I am trying to run: @RunWith(classOf[JUnitRunner]) class CategorizationSpec extends FlatSpec with BeforeAndAfter with Matchers{ var ss:SparkSession = _ before{ …
0
votes
0 answers

Testing Controller action in play framework 2.4 wih scalatest

I am trying to test my controller action in Play Framework with ScalaTest . I have read play documentation and trying to run the given sample to get started my controller Application.scala class Application extends Controller { def index1() =…
M.Ahsen Taqi
  • 965
  • 11
  • 35