547 questions
0
votes
0
answers
88
views
Json matcher stop matching after migration to specs2 4.22
I have a small specification that uses json matcher
import org.specs2.matcher.JsonMatchers
import org.specs2.mutable.Specification
class Test extends Specification with JsonMatchers {
"test&...
0
votes
0
answers
44
views
spec2-html Fails on Windows with a Path Written in Unix-like Style
I'm trying to get HTML output for the specs2 tests I start with sbt. However, the template html file which does exist in my Scala project at the expected location is not found. The error message ...
0
votes
1
answer
129
views
Specs 2 - I want to mock one of the injected modules into the controller class
Let's say I have a class which has 10 auto injected items:
@Singleton
class ExampleClass @Inject() (
implicit
configuration: Configuration,
secondModule: SecondModule,
thirdModule: ThirdModule,...
0
votes
0
answers
237
views
Cannot invoke "java.lang.Integer.intValue()" specs2 mocking a method that returns int
I am using following configuration to run a test case using specs2 specification and specs2 mockito and mocked a method that is supposed to return int but it gives following error.
java.lang....
0
votes
0
answers
133
views
Specs2 mockito throws NoSuchMethodError
I have a Scala project based on play framework. I am using specs2 mockito and specifications for test cases. When running the test cases, I am getting following error:
Exception in thread "specs2-...
0
votes
1
answer
107
views
How to get spec2 to show full stack trace with `not(throwA(...))`
If I have a specs2 test like the following:
import org.specs2.mutable.Specification
import scala.util.Try
class Tests extends Specification {
def foo(): Unit = throw new Exception("oops")...
0
votes
1
answer
130
views
Find specifications by pattern in scala specs2
We have an issue with different environments for our integration tests and start/stop latency.
So, we want to run all environment dependencies before all integration tests and shut down after all.
We ...
1
vote
1
answer
722
views
How to use Mockito "verify" with "eventually" of specs2?
I am writing a test with specs2 and mockito in Scala. The test should verify that a function foo running asynchronously calls barMock.bar()
In order to verify the barMock.bar() call I can use verify :
...
0
votes
0
answers
80
views
the specs2 beRight matcher is not type-checked - is there an equivalent one that is?
Specs2 has these Either matchers:
private[specs2]
trait EitherBaseMatchers {
def beRight[T](t: ValueCheck[T]) = RightCheckedMatcher(t)
def beRight[T](implicit p: ImplicitParam = implicitParameter)...
0
votes
0
answers
145
views
Running Specs2 with Quarkus
I am trying to run Specs2 with Quarkus. My test classes are annotated with @QuarkusTest. When I try to run the tests with maven, it does not find any tests.
I tried adding the @RunWith(classOf[...
1
vote
2
answers
306
views
Can Specs2 Result.foreach be made to work like a matcher?
Using Specs2, if I do:
1 must beEqualTo(2)
1 must beEqualTo(1)
The test fails (as expected)
If I do:
Result.foreach(1 to 10) { i =>
i must_== 2
}
Result.foreach(1 to 10) {...
3
votes
2
answers
858
views
Scala Type Parameter with Either
class OptionLikeMatcher[F[_], T, U](typeName: String, toOption: F[T] => Option[U]) extends Matcher[F[T]] { ... }
case class RightMatcher[T]() extends OptionLikeMatcher[({type l[a]=Either[_, a]})#l, ...
1
vote
1
answer
137
views
Specs2: skip inherited test suite
In specs2, given the following code:
import org.specs2.mutable.SpecificationWithJUnit
trait TestSuite extends SpecificationWithJUnit {
...
}
class ConcreteTest extends TestSuite {
// want to skip ...
1
vote
1
answer
294
views
Running specs2 test on IntelliJ throws InvocationTargetException
I have Scala Play project which uses specs2 as the test framework. I'm having difficult time running the tests from IntelliJ. I get the following error:
InvocationTargetException for 'main' in org....
2
votes
0
answers
2k
views
Did not find suite classes in package Intellij IDEA
I have a poly repository kind project in Intellij IDEA built with Pants. Individual modules are built with sbt. So I want to debug Specs2 tests using Intellij IDEA debugger. I moved the module I need ...
1
vote
1
answer
67
views
Use specs2.runner with own notifier from command line
How can I call a self-written spec2 Notifier from the Java command line without using sbt.
I want to do this:
java -cp "testJars/*" org.specs2.runner.files "**/*" <here add ...
0
votes
1
answer
187
views
Running list of specs2 specifications from a single spec2s parent specification
I am currently working on maven based scala project with a bunch of specs2 specification tests and am using Intellij 2020.2 and scala 2.12.10 with specs2 version 4.9.4
I am able to run each ...
0
votes
1
answer
276
views
Scala/Play: Test class: reading a custom configuration file from the /conf folder
Using Play 2.7. In a test class, I want to test a service that reads the configuration (properties) file conf/fun.conf.
I could not find any example how to carry out this feat. I have looked at the ...
0
votes
1
answer
187
views
Scala / Specs2 : def is(implicit ee: ExecutionEnv) = { "Service" should {...} }
I try to upgrade a Scala/Play project to Play 2.7, Scala 2.12.11, Specs2 4.5.1.
In the project there is the following Specs2 test that I cannot understand in the sense of its Specs2 specification ...
0
votes
1
answer
2k
views
Scala / specs2 : could not find implicit value for evidence parameter of type AsExecution[ExecutionEnv => MatchResult[Future[AuthenticationResult]]]
I am trying to upgrade a Scala/Play application to Play 2.7, Scala 2.12.11.
I have the following test that probably used to work before I upgraded Play and Scala.
After the upgrade, I got the ...
1
vote
1
answer
2k
views
Is there a way to mock LocalDateTime timestamp using specs
I am supposedly contributing to the integration tests of a library which relies on specs with the underlying implementation written in Scala. The testing is more bind towards the stream of events ...
2
votes
1
answer
813
views
Matchers for cats EitherT and effects
I'm new in cats and functional programming and I'm struggling with unit testing functional data types like EitherT. Having example code:
class Library[F[_]]() {
def create(book: Book)(implicit M:...
7
votes
1
answer
413
views
Create assembly jar that contains all tests in SBT project+subprojects
I have an interesting problem where I basically need to create a .jar (plus all of the classpath dependencies) that contains all of the tests of an SBT project (plus any of its subprojects). The idea ...
5
votes
2
answers
173
views
Existing data for tests is not found Scala Specs2
I am building the integration tests which would read the data generated after the previous test cases and check it with expected result. When I run the tests the generated data is not visible in the ...
0
votes
1
answer
70
views
upgrading specs2 version leads to an error
I upgraded specs2 version from 2.4.12 -> 3.8.9 and when I run a test an error has been occured :
[error] the pandoc executable is not available at: pandoc
[error] Error: Total 6, Failed 4, Errors 1, ...
1
vote
2
answers
199
views
Compare only string part inside case class
Is it possible to compare only part of string in property of case class.
Using scala specs2 lib.
Is there is a possibility to write such matcher?
CaseClass(property = Prop("very long string")) must ...
0
votes
1
answer
531
views
SBT dependency conflict between two specs2's versions jars?
I upgraded play framework to version 2.4, but in my jars file I still see specs2 version 2.4.13 jars that I did not understand their origin, since play framework 2.4 uses specs2 independently this ...
0
votes
0
answers
67
views
object TagFragments is not a member of package org.specs2.specification
I have recently upgraded play version to 2.4 coming from 2.3, Since I'am using specs2 for writing tests, I needed to add the following line to the sbt file:
libraryDependency += specs2 % Test
...
0
votes
1
answer
89
views
Specs2 unit specification referencing
I've got the following spec:
import org.specs2.mutable.{After, Specification}
import org.specs2.specification.Scope
import org.specs2.specification.core.{Fragment, Fragments}
class TestRefSpec ...
3
votes
1
answer
140
views
Why does ScalaTest by default not enforce types when matching?
I was wondering why ScalaTest behaves differently compared to Specs2.
Specs2
"" must be equalTo 3
TestSpec.scala:11:26: type mismatch;
[error] found : Int(3)
[error] required: String
[error] ...
2
votes
2
answers
458
views
Scala, Specs2 and shared state
I am writing some Specs2 specifications; that looks like:
class ComponentSpecification extends Specification with Mockito {
private val dependency = mock[Dependency]
private val subject = new ...
0
votes
1
answer
361
views
Specs2 and Scalacheck - mixing ForEach context with properties
I'm writing Specs2 tests that use a temporary file and properties from ScalaCheck. Without properties it works fine :
import better.files.File
import org.specs2.execute.{AsResult, Result}
import org....
2
votes
2
answers
1k
views
NoSuchMethodError in Mockito with Specs2
I upgraded a Play 2.6 project to Play 2.7. The project compiles, but I get a NoSuchMethodError in a test:
Exception in thread "specs2-8" java.lang.NoSuchMethodError: org.mockito.internal.progress....
0
votes
1
answer
375
views
Applying evolutions to ScalikeJDBC in-memory test DB
I'm using ScalikeJDBC with Play. I want to apply evolutions to an in-memory database for my Specs2 tests.
import org.specs2.mutable.Specification
import org.specs2.specification.BeforeAfterAll
import ...
0
votes
1
answer
120
views
Gherkin-like examples in Specs2
The Gherkin-like syntax is very useful to put examples at the bottom of the specification and unfortunately it seems from the documentation that Specs2 doesn't support it. (Although it supports Tables,...
1
vote
2
answers
993
views
How to create test fixtures for every example of a functional test
Scala noob here.
I currently try to create functional tests for a Play (Scala) based web application using specs2. The examples themselves are simple, i.e.:
class SignInSpec extends ...
2
votes
1
answer
246
views
Creating an anonymous class from an abstract class in Scala - desugaring code
Scala noob here.
I don't understand the following piece of code, taken from a Play application's integration test (Scala):
package workflows.admin
import play.api.test._
class SignInSpec extends ...
2
votes
2
answers
243
views
How to unit-test different typeclass instances for Numeric?
Let's say I have two instances of the typeclass Numeric.
class Money(c: String, x: Long, y: Int)
class Quantity(c: String, x: Long, y: Int)
implicit val numericMoney: Numeric[Money] = new Numeric[...
0
votes
0
answers
991
views
scala specs2 mocking a http client response
I am trying to write a unit test for a specific method which calls a REST endpoint with given inputs(url, http method, body, headers). Below is the code.
def genericAPICall(uri: String, method: ...
2
votes
1
answer
383
views
specs2 mock methods in a scala trait never verified
I am trying to mock my interactions with an external API that checks a token to see if the user is authorized to perform certain actions (it is currently a seperate API as a PoC that is going to be ...
0
votes
1
answer
138
views
How to stack behaviour with traits extending BeforeAfterAll
I'm in a situtation where I have 2 traits extending BeforeAfterAll doing different actions for integration tests: One managing the database and the other the file system. For example:
trait ...
0
votes
2
answers
2k
views
How to Mock akka Actor for unit Test?
@Singleton
class EventPublisher @Inject() (@Named("rabbit-mq-event-update-actor") rabbitControlActor: ActorRef)
(implicit ctx: ExecutionContext) {
def publish(event: Event): Unit = {
logger....
3
votes
1
answer
1k
views
Can Specs2 compare sequence elements with one of the existing matchers?
I want to compare 2 sequences of doubles in a specs2 test, something along the lines of:
actualValues must containTheSameElementsAs(expectedValues, _ beCloseTo _)
I can write a manual comparison like ...
0
votes
1
answer
34
views
Specs2 how to test Give/When/Then style in a separate text file
I need a way to unit test a play scala project using Specs2's Given/When/Then style but the acceptances is written in the text file in like how it is in Jbehave.
1
vote
1
answer
244
views
Premature end of file in Play controller unit test
I'm writing a new Scala Play 2.6 web service, and trying to write a unit test for a controller that accepts XML payloads. When I call the controller from the unit test, however, I get a 400 returned ...
0
votes
1
answer
847
views
Specs2 version 4 - how to use Future matchers (such as `awaitFor`)
Upon upgrading to specs2 version 4, our tests which were using Future matchers started to fail.
This is what those tests look like:
class SomeSpec(implicit ee: ExecutionEnv) extends Specification {
...
3
votes
1
answer
2k
views
Scala: Mock init fails with Cats IO type parameter
While writing tests I'm confronted with the following exception:
java.lang.ClassCastException: codegen.java.lang.Object$MockitoMock$641592186 cannot be cast to cats.effect.IO (MyRepositorySpec.scala:...
0
votes
1
answer
516
views
Play: Cannot resolve symbol PlaySpecification
I cannot import PlaySpecification.
First, it seems to be part of Specs2, but after importing specs2 it doesnt'show up.
https://playframework.com/documentation/2.6.x/ScalaFunctionalTestingWithSpecs2#...
0
votes
1
answer
389
views
overloaded method value route with alternatives
I'm getting this error (overloaded method ) for method route, status, contentAsJson. Any ideas why?
import play.api.test._
import play.api.test.Helpers
import play.api.libs.json.Json
class ItemsSpec ...
1
vote
0
answers
53
views
Play Framework Specs2 Test - FakeApplication in multi-project
I've read https://www.playframework.com/documentation/2.4.x/SBTSubProjects to create a project composed of multiple Play applications.
There are three Play sub-projects in modules directory.
I need to ...