spock Questions

1

Solved

I have a small problem. I have started writing tests for my small project. The project uses SpringBoot, standard JpaRepository from Spring, as a testing framework I am using Spock and for testing t...
Episternum asked 16/12, 2021 at 21:12

3

Solved

I m new to Spock, tried to write a simple Spock but it failed: Error:Groovyc: Could not instantiate global transform class org.spockframework.compiler.SpockTransform specified at jar:file:.../.m2/...
Guardianship asked 30/10, 2016 at 5:54

3

Solved

I have a switch statement to handle an java enum foo, and am using spock to write some groovy unit tests. I have already added a test which verifies that every type of foo is currently handled with...
Dorotea asked 13/3, 2015 at 14:14

2

My tests are located in different classes which extended from BaseSpec class that in turn extended from Specification class of Spock Framework. class BaseSpec extends Specification { def setupSpe...
Roister asked 13/6, 2020 at 12:34

2

Solved

Can spock mock final classes? If so, how? Search results brought up this gist, which would seem to imply so, but I can't find any examples of doing so. I've also found forum posts that say mocking ...
Lightfooted asked 6/12, 2015 at 20:0

2

Solved

I am new to spock. I am trying to write a spock unit test against a standalone java app that uses JDK 1.7, Spring 3.1, Groovy 1.8.6, Spock 0.6, Maven 3.0.4. A basic hello world spock test is workin...
Kavita asked 21/3, 2012 at 19:14

3

Solved

I'm looking for advice on how to get the port that was assigned to the embedded Tomcat that is serving the actuator endpoint when setting management.port property to 0 in integration tests. I'm usi...
Secondhand asked 12/4, 2016 at 8:7

0

I'm trying to upgrade a Spring Boot (2.1.4.RELEASE) project from Spock 1.3 to 2.0. Unfortunately, I'm getting No tests found for given includes: for any test I try to run. Here is a build.gradle sn...
Fant asked 19/7, 2021 at 19:40

4

Solved

On a previous project I used the Spock testing framework to unit test my Java code. I found this really productive so I am trying to add Spock tests to my current project which uses Maven as its bu...
Pettifogging asked 7/8, 2014 at 15:9

2

I'm not sure if I'm misusing interaction based testing or if I'm doing something conceptionally wrong. I'm working on a Spring Boot Application (Kotlin) and my tests are using Spock/Groovy. I have...
Hoarding asked 30/4, 2019 at 7:58

2

Solved

I'm running 9 JUnit (Spockframework actually) tests in Intellij IDEA. It takes about 3 seconds. I want to make use of all of the cores, therefore I switch test configuration fork mode - class. Edi...
Killjoy asked 17/4, 2015 at 12:22

3

Solved

I'm testing error handling. I want the first call to mockedObject.foo() to throw a new IOException, and the second to return bar. I tried the following code, mockedObject.foo() >>> [{thro...
Fluorite asked 27/10, 2015 at 15:58

4

Solved

Groovy/Gradle project here that uses Spock for unit testing. Does Spock and/or Gradle support test suites or named sets of tests? For reasons outside the scope of this question, there are certain ...
Reinareinald asked 24/2, 2016 at 21:8

1

I need to execute block of code once upon startup on the Spock tests. I cannot use @Autowired in setupSpec() which is default method for such initialisation, however @Beans would not be loaded till...
Communicable asked 28/1, 2021 at 11:17

1

Solved

I have an integration test that's using @SpringBootTest to spin up a Spring application context that's testing a simple Spring Boot app. I'm using Spock for writing the tests, my build tool is Mave...
Panelboard asked 27/1, 2021 at 14:28

0

Is there a way to have nested tests like JUnit 5 in Spock? There are a lot of tests for a particular class and I want to group them for better understanding and easy viewing. JUnit offers Nested te...
Aged asked 24/12, 2020 at 13:2

2

Solved

Using the most basic example from Mockito's examples page, I am able to run successfully in JUnit. However, when I run the same test in Spock, it fails. JUnit/Java version (this passes): import...
Assist asked 21/5, 2013 at 19:38

1

Solved

I am currently writing unit testcase for a groovy application class Page{ .. .. str1 = obj.getDateBasedOnValue("A"); str2 = obj.getDateBasedOnValue("B"); } Test class class...
Semicolon asked 13/11, 2020 at 7:53

2

Solved

My E2E tests are running pretty slowly (25 minutes) as they call a bunch of services and wait for some data to be populated in the database. I want to run it concurrently. I'm using the following m...

1

I'm trying to set up testing environment with testcontainers and flyway in spring boot application. All this supposed to run via DinD scheme. Current test example as follows: import com.testapp.t...
Trichomoniasis asked 11/10, 2019 at 15:11

2

Solved

I come from Java background and am new to Groovy-Spock testing. I need to convert a list in Json to a List. I cannot share the exact code (proprietary), but here is in essence what is going on. em...
Moultrie asked 27/11, 2018 at 21:17

2

Solved

I wanna spy method calls of Spring bean. I checked docs - Spock can create spy only by constructor. Can Spock wrap already existing object by spy?
Howdoyoudo asked 6/2, 2015 at 15:42

4

Solved

I don't understand the difference between Mock, Stub, and Spy in Spock testing and the tutorials I have been looking at online don't explain them in detail.
Varner asked 25/6, 2014 at 15:46

2

Solved

Here is my Spock unit test: def "when favorite color is red then doSomething produces empty list of things"() { given: FizzBuzz fizzBuzz = Mock(FizzBuzz) fizzBuzz.name >> 'Dark Helmet' f...
Reservist asked 12/1, 2016 at 12:51

2

Solved

When I run a test in Gradle I would like to pass some properties: ./gradlew test -DmyProperty=someValue So in my Spock test I will use to retrieve the value: def value = System.getProperty("myP...
Shingle asked 17/6, 2019 at 10:2

© 2022 - 2024 — McMap. All rights reserved.