2,405 questions
Score of 1
1 answer
188 views
Mock Java constructors while testing Java-code
I use Spock to test Java-code. For example, I have the following Java-class:
public class Github implements RemoteRepository {
@Override
public Boolean isBranchExist(String branch) {
...
Score of 0
1 answer
136 views
Duplicate Content-Type header in Spring REST Docs using RestAssuredMockMvc
I'm currently writing tests using RestAssuredMockMvc together with Spring REST Docs.
Setup
In my global spec setup, I configure the headers like this:
package com.animore.config
import com.fasterxml....
Score of 2
1 answer
58 views
Spock automatic logging
Due to some special need, I'd like to have test written in Spock be automatically logged in each sub-section.
For example
class FooSpecification extends MyBaseSpecification {
def "A test"()...
Score of 0
0 answers
93 views
Can I Use @QuarkusTest to Replace JerseyTest in Spock Specifications?
I have many Spock specifications like the next one, that act as "unit tests" for the resource classes of a project. This is an Open Liberty application and now there's a need to migrate it ...
Score of 1
1 answer
65 views
Dynamically append value to spock test method name based on method annotation
We have a large Spock test suite, across mulitple teams, each teams tests have an annotation on them such as @Team5.
I would like to append - @Team5 dynamically to the end of each test methods name ...
Score of 2
1 answer
65 views
How to mock interaction from method outside of Spec in Spock
I have a mocked object
userService = Mock()
and a mocked interaction
userService.test("test") >> "result"
How can I define this interaction in another class/method ?
Maybe &...
Score of 0
1 answer
60 views
How to mock with Spock
I want to mock with Spock a method getEntity for the Spring ResTemplate
Product getProducts(ProductSearch request) {
Map<String, Object> queryParam = new HashMap<>();
queryParam.put(&...
Score of -1
1 answer
128 views
Spock Mock Not Working, Test Throws NullPointerException
I have a problem with mocking in the spock, my variabla systemTaskOptional is null, test throwing an error. Here is my code of test, and part of code with biznes logic, where is null throwing.
def ...
Score of 1
1 answer
436 views
Spock happens exception:Too few invocations for: xxxx Unmatched invocations (ordered by similarity)
I use Spock to test my java code,in detail to test method is MnsTemplate's sendMessage Method and unit test is in MnsTemplateTest, they are in below code.
In this unit test, I mock MNSClient、...
Score of 2
1 answer
34 views
Grail, GORM, Spock: An association from the table [X] refers to an unmapped class: [Y]
I'm getting this error in a Spock test after adding a new association to one of the domain objects that this service uses. I haven't found any Grails-related or GORM-related questions referencing this ...
Score of 0
1 answer
87 views
Test SpringBoot Webclient in Groovy throwsNullPointerException in put call
I am testing a Java method that uses Spring Boot WebClient to make a PUT request and returns void. The test is written in Groovy. This is the method I want to test:
public void putProcessing(final ...
Score of 0
1 answer
53 views
How to use database methods in grails spock specification tests?
I am going to test some classes test using specification test with spock.
Some methods uses Domain.list() and it not available via light specification test.
Of course I could replace Domain.list() ...
Score of 1
1 answer
98 views
How to mock random static method: RandomStringUtils.random
I have following easy file random.groovy in "vars" folder and Im trying to test with groovy 2.4 and spock testframework 1.3-groovy-2.4. The file is basically about generating random ...
Score of 0
1 answer
223 views
Mock new Date or System.currentTimeMillis
I am setting up tests using Groovy and the Spock framework. My tests depend on the passage of time, and the services in question use new Date() for some rules. Because of this, I would like to modify ...
Score of 0
1 answer
74 views
HTTP Connection Error in cleanupSpec() Function in Spock: "SSL is disabled"
I'm encountering an issue when making an HTTP request in the cleanupSpec() function of a Spock test. The same HTTP GET request works perfectly in both the test case and the cleanup() function, but ...