spock Questions

6

Solved

As described here @Repeat annotation is not supported right now. How can I mark spock test as repeated n times? Suppose I have spock test: def "testing somthing"() { expect: assert myService.ge...
Zigrang asked 6/6, 2012 at 7:39

5

Solved

In JUnit / Mockito we have 2 extremly useful annotations: @Mock and @InjectMocks. In my new project i started using groovy with spock for testing, I'm wondering if there is a replacement for ment...
Quest asked 11/12, 2013 at 19:56

3

Solved

So I have a class that has a method that logs a message: class Car { private Logger logger = LoggerFactory.getLogger(Car.class); void startCar() { logger.error("car stopped working"); } } ...
Subtraction asked 26/6, 2014 at 19:58

4

Solved

Setting up a new spring boot java project using groovy Spock unit tests in IntelliJ IDEA. I cannot get my first unit test to run. I created it from inside IntelliJ and it is under src/test/groovy. ...
Venola asked 8/10, 2020 at 17:2

4

I had to update Spring Boot starter from 2.1.4.RELEASE to 2.2.6.RELEASE, but now the integration tests are failing. My tests are in Groovy, my application is written in Java. They runned well with ...
Wombat asked 30/10, 2020 at 21:2

2

I'm writing a java library foo which has a dependency on bar:1.1+. But library bar has changed quite a bit over the time, and I'd like to ensure my library is compatible with every version of bar (...
Emanative asked 11/8, 2015 at 18:11

2

Solved

I have the following parameters for the same test: a | b | c 1 | 2 | 3 11 | 22 | 33 Spock provides the @Unroll annotation for tests similar to this (with this set of parameters you can run to...
Convolvulus asked 10/8, 2017 at 19:47

5

Solved

I test my application using Spock framework, the tests are written in Groovy. As a result of some method evaluation I have a list of objects. I want to test if this list is the same as the list I ...
Laveta asked 9/10, 2014 at 16:49

3

Solved

I have a method like below in my class that I'm trying to test: class SomeHelper { ByteArrayOutputStream fooBar (Request request) { ByteArrayOutputStream baos = someParser.parseData(getRequestF...
Dorsman asked 23/7, 2017 at 9:21

4

Solved

I have a list of some objects - let's assume companies. Now I want to check if this list contains companies with some names but not taking order into consideration. Currently I'm using such constru...
Cobweb asked 11/2, 2015 at 10:2

2

Solved

I started playing with testcontainers and at the beginning of my journey I faced some issue (below). I did similar thing for mysql db and it worked fine. Do I miss some mongo specific config? Acco...

4

Solved

I have a Groovy class annotated with @Slf4j, so it gets a private final Logger log field, whose usage I'd like to test. I want to continue using @Slf4j and not expose the log field any further just...
Exudate asked 21/5, 2015 at 11:17

2

Solved

I have a simple Spock specification annotated with @SpringBootTest and the class under test annotated with @Autowired, but the test subject is null in the unit test. The controller is annotated wit...
Pozzy asked 18/2, 2023 at 1:11

2

Solved

I write a Groovy script and I need to access a field that has a private access modifier. This works fine but generates a warning: Access to <field_name> exceeds its access rights I want to...
Angularity asked 13/5, 2019 at 11:15

2

I am trying to run tests in parallel on my laptop, which has 4 pyhsical and 8 logical CPUs. ➜ sysctl -n hw.ncpu 8 ➜ sysctl -n hw.physicalcpu 4 I would like to run at most 4 tests in parallel. This...
Ce asked 5/4, 2019 at 9:48

3

Solved

Given json such as {"arr1" : [1,2,3], "arr2" : []} where it is known that there are arrays named arr1 and arr2, is there a jsonpath expression for the length of an array that will work for both...
Reflective asked 16/7, 2014 at 8:24

1

Solved

I created simple project with the newest Spring Boot 3 and spock versions, which you can find here: https://github.com/RafBorkowski/SpringBoot3SpockExample. When I try to start test with junit, con...
Unstop asked 30/11, 2022 at 19:52

2

Solved

I'm currently working with: Micronaut 3.7.3 RabbitMQ 3.11.2 Spock Groovy / Java 17 I'm implementing a rabbitmq consumer for a simple demo project following the guidelines from micronaut project (...
Dimphia asked 16/11, 2022 at 16:7

5

Solved

First-timer here, apologies if I've missed anything. I'm hoping to get around a call to a static method using Spock. Feedback would be great With groovy mocks, I thought I'd be able to get past th...
Moonshine asked 5/4, 2013 at 1:9

6

Solved

I have some Java stuff like this: public interface EventBus{ void fireEvent(GwtEvent<?> event); } public class SaveCommentEvent extends GwtEvent<?>{ private finalComment oldComme...
Snowshoe asked 1/3, 2014 at 6:54

4

Solved

I have a class that I want to test in that looks like this: package com.something; import org.springframework.beans.factory.annotation.Autowired; public class ClassToTest implements InterfaceToTes...
Chanticleer asked 10/8, 2016 at 15:58

2

Solved

How do I programmatically skip a test in the Spock framework? I know I can annotate a test with @Ignore to skip it, or use @IgnoreIf to skip tests based on environmental variables and the like. But...
Polymerize asked 20/11, 2015 at 4:17

3

Solved

How can you unit test a class that has a superclass in Spock that invokes method calls form its superclass? Or how do you mock a superclass in Spock? Ex: class Bar { def method1(parm1){ //Me...
Pibgorn asked 30/6, 2014 at 1:45

4

Solved

How do I check for deep object equality with spock. Lets say we have a super simple test that compares to identical person objects def "A persons test"() { setup: def person1 = new Person("Foo...
Polyglot asked 19/11, 2017 at 8:37

4

I'm running Spock tests by "Right click -> Run -> Test Name". How can I run tests in debug mode? Debug icon run tests but doesn't stop on breakpoints
Martsen asked 11/5, 2012 at 8:5

© 2022 - 2024 — McMap. All rights reserved.