Open mkluzacek opened 4 years ago
Check that
context.setTarget(new AmpqTestTarget(Collections.singletonList("my.package.pact")));
has the correct package for you message handler.
I've added your test to https://github.com/uglyog/pact-maven-amqp-test (see https://github.com/uglyog/pact-maven-amqp-test/blob/master/provider/src/test/java/com/github/uglyog/mavenamqp/UserPactTest.java).
That project works, so you should be able to compare it to yours.
Thank you very much for your help. I was finally able to fix it. Problem was the dependency. I was using:
<dependency>
<groupId>au.com.dius</groupId>
<artifactId>pact-jvm-provider-junit5_2.12</artifactId>
<version>3.6.14</version>
</dependency>
Instead of :
<dependency>
<groupId>au.com.dius</groupId>
<artifactId>pact-jvm-provider-junit5</artifactId>
<version>4.0.7</version>
<scope>test</scope>
</dependency>
No idea where i found the first one. Thanks again.
That was the old (pre-4.x) dependency.
SpringBootHttpTarget also cannot find annotated methods.
The following is my code of Pact in Provider:
@RunWith(SpringRestPactRunner.class)
@Provider("user")
@PactBroker
@ActiveProfiles("local")
@SpringBootTest(
classes = EquipmentServiceLauncher.class,
webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT
)
public class EquipmentsProviderPact {
@Autowired
private UserRepository userRepository;
@TestTarget
public final SpringBootHttpTarget target = new SpringBootHttpTarget();
@PactVerifyProvider(value = "GET User BY ID")
public Map<String, Object> setupUser() {
...
}
}
@Norman-else looks like you are using the wrong annotation. Is that method a state change handler? If so, it should be annotated with the @State
annotation.
I upgraded a service to Java 11 + Junit 5, got the same problem. In my case it was because of a trailing star in the packages list:
@TestTarget public final Target target = new AmqpTarget(Collections.singletonList("com.example.my.package.*"));
which had to be replaced with (no star at end of package):
@BeforeEach
void before(PactVerificationContext context) {
context.setTarget(new MessageTestTarget(List.of("com.example.my.package")));
}
Hi, i am having the same issue as mentioned here https://github.com/DiUS/pact-jvm/issues/763.
Using:
And :
My test looks like this:
I've tried multiple version of surefire plugin, tried using empty constructor for AmpqTestTarget but everything ends with:
user created message No annotated methods were found for interaction 'user created message'. You need to provide a method annotated with @PactVerifyProvider("user created message") that returns the message contents.
The test doesnt work from both IDE(Intellij) and maven. I just cant get it to work so any help would be appreciated.