Questions tagged [scalamock]

ScalaMock is a mocking framework for the Scala programming language.

ScalaMock provides fully type-safe mocking support for almost all Scala language features including:

  • mocking classes, traits and case classes
  • mocking functions and operators
  • mocking type parameterized and overloaded methods
  • support for type constraints
  • support for repeated parameters and named parameters
  • mocking Java classes and interfaces

The official Web site for the ScalaMock project is http://www.scalamock.org.

148 questions
0
votes
0 answers

Scalamock 3 with Java Interface

I'm having trouble getting Scalamock 3 to mock a Java interface. I'm trying to run describeInstances on AWS. The call requires an EC2 client which I mocked with the method described in the tutorial. I get the error: Error:(20, 42) type mismatch; …
seanmcl
  • 9,740
  • 3
  • 39
  • 45
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

ScalaMock a method with two parameter groups

How exactly should I mock something like this (the post method of Play's WSRequest from the WS library): def post[T](body: T)(implicit wrt: Writeable[T], ct: ContentTypeOf[T]): Future[WSResponse] I've read through the ScalaMock page about this and…
Andy Hull
  • 1,843
  • 2
  • 14
  • 16
0
votes
1 answer

missing dependency detected during test using scalamock

I'm trying to use scalamock / scalatest and I always have an error during testing My build.sbt name := "name" organization := "org" version := "1.0-SNAPSHOT" scalaVersion := "2.11.7" scalacOptions ++= Seq("-feature",…
Alexandre T
  • 648
  • 2
  • 8
  • 24
0
votes
2 answers

Mocking Play WSRequestHolder get method using Scalamock

I'm trying to test the following line of code using ScalaTest and ScalaMock. val responseFuture = wsClient.url(url).withQueryString(params: _*).get() wsClient type is THttpClient, which is a wrapper of play.api.libs.ws.WS. Given that: val…
user2664655
  • 251
  • 1
  • 3
  • 9
0
votes
2 answers

Verifying that the no arg version of an overloaded function gets called in scalamock

I am using scalamock and am trying to verify that the close() method in the RabbitMQ com.rabbitmq.client.Channel class is getting called. The problem is the close() method is overloaded with two options: close() and close(int, String). I want to…
rancidfishbreath
  • 3,944
  • 2
  • 30
  • 44
0
votes
1 answer

Scalamock scalatest - Not able to stub

I have created a Workflow Processor Trait similar to the one mentioned below: import org.scalatestplus.play._ import play.api.mvc._ import play.api.test._ import play.api.test.Helpers._ import org.scalatest.Matchers._ import…
0
votes
1 answer

Scalamock testing Java dependency injection

I use Scalamock for unit testing my Java project. Project contains classes that use Java CDI style DI: class Resource { @Inject private Service service; ..... } How can I inject mock as a Service instance? With Mockito I'm able to use…
0
votes
1 answer

Test a nested method call on a mocked class using ScalaMock

I am new to both ScalaMock and mocking in general. I am trying to test a method which calls a method in another (mocked) class and then calls a method on the returned object. Detailed information: So I am using ScalaTest and there are five classes…
bytecode
  • 1
  • 2
0
votes
1 answer

How can I use scalamock to stub WSRequestHolder.post() in Play

I'm having trouble using scalamock to stub the post() method in WSRequestHolder in the Play WS library. Here's what I'm trying: (request.post[Results.EmptyContent](_ : Results.EmptyContent)(_ : Writeable[Results.EmptyContent], _:…
DrewEaster
  • 3,316
  • 3
  • 35
  • 39
0
votes
1 answer

ScalaMock verifying a generic method returning Unit gives method overloading compile error

This following code: import org.scalamock.scalatest.MockFactory import org.scalatest.FlatSpec case class Container[T](value: T) trait Service[T] { def doWork(value: T): Unit } class DoesMatch[T](service: Service[T]) { def doMatch(container:…
simbo1905
  • 6,321
  • 5
  • 58
  • 86
-1
votes
1 answer

How i can mock method with many bracers?

I have method: get[T](method: String, additionalHeaders: (String,String)*)(block: HttpResponse => Try[T]): Future[T] I try like this: var serviceClient = mock[ServiceClient] (serviceClient .get _).expects(*, *) But get…
iluxa1810
  • 278
  • 3
  • 12
-3
votes
1 answer

Dependency mocking in scala

class Service1 @Inject()(service2: Service2) { val url = service2.REDIS_URL } class TestService @Inject()(service1: Service1) { def foo() => {} } I have the above 2 classes. I need to test TestService.foo. Following is the code that I am trying…
Ashwin Sreekumar
  • 121
  • 1
  • 12
1 2 3
9
10