//2.spock depency pom.xml <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <parent> <artifactId>internal-control-parent</artifactId> <groupId>com.ctjsoft</groupId> <version>0.0.1-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <artifactId>spocky</artifactId> <dependencies> <dependency> <groupId>org.spockframework</groupId> <artifactId>spock-core</artifactId> <version>2.0-groovy-2.5</version> <scope>test</scope> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.codehaus.gmavenplus</groupId> <artifactId>gmavenplus-plugin</artifactId> <version>1.12.1</version> <executions> <execution> <goals> <goal>compile</goal> <goal>compileTests</goal> </goals> </execution> </executions> </plugin> <plugin> <artifactId>maven-surefire-plugin</artifactId> <version>2.22.2</version> <configuration> <useFile>false</useFile> <includes> <include>**/*Spec.java</include> </includes> </configuration> </plugin> </plugins> </build> </project>
@unxia, have you tried using Spock's Spring integration?
If something is not working as expected there, it would make sense to publish an MCVE on GitHub in order to illustrate your problem. Writing one sentence, saying "I want to do A, similar to project B" does not quite precisely describe your problem.
@SpringSpythe bean that receives the message. Occasionally this test fails with "too few invocations" on the spied on bean. Upon further inspection, when it fails, the bean appears as class
GCPPubSubReceiverand when it passes, as class
@SpringSpyruns first, then it does
I have a bug suggestion regarding using of DetachedMockFactory to test spring-cloud-stream functions.
When spring test context is created by TestChannelBinderConfiguration and depency is created by DetachedMockFactory, the mocking itself didn't happen. Mock has been created, but method call isn't. Here is screenshot: https://i.stack.imgur.com/4G74V.png
In the test wrote via junit5 all is good and working.
I created sample project to demonstrate this issue: https://github.com/serjteplov/demo-kafka-mock.git