https://linen.dev logo
Title
s

Shruti Mishra

05/05/2023, 8:59 AM
Getting this below error...404 cannot register stub. I am trying to run in spring boot.
b

Bas Dijkstra

05/05/2023, 11:02 AM
Hi @Shruti Mishra, why are you assigning the stub definition to the
wiremockRule
object and not to the
wiremockServer
object?
s

Shruti Mishra

05/05/2023, 11:03 AM
Ahh Okay @Bas Dijkstra will try with wiremock server in place of wiremockRule
Tried with WiremockServer in place of WireMock Rule @Bas Dijkstra but still the same 404 error is being thrown.
b

Bas Dijkstra

05/05/2023, 12:32 PM
(Isn't there a way to properly post the code in Slack instead of in a screenshot? This is very hard to read...) I think you've got a different problem here... It looks like the only thing your test method is doing is adding a stub definition to your WireMock instance. Are you trying to call that in another test? There's a good chance you're spinning up the WireMock server anew for every test, which means that your stub definition isn't registered when you run the actual test. Try adding the stub definition and running the actual test in the same
@Test
method 🙂
s

Shruti Mishra

05/05/2023, 12:40 PM
@Bas Dijkstra Actually the code is in my system where I do not have the access to open the slack. Apologies for the same! Just wanted to confirm one point over here that, if we put @test annotation on the method, then is it possible to deploy that particular url in server...or in wiremock it is only written for testing purpose. Thanks.
b

Bas Dijkstra

05/05/2023, 12:47 PM
No,
@Test
is an annotation used by your testing framework (JUnit or TestNG). It identifies a method as a test method.
s

Shruti Mishra

05/05/2023, 12:50 PM
Actually my requiremnt is to deploy the url in the server...in that case will wiremock work using spring boot?
b

Bas Dijkstra

05/05/2023, 1:25 PM
I have no idea what 'deploy the url in the server' means, sorry. Maybe someone else does. Have you had a look here? https://docs.spring.io/spring-cloud-contract/docs/current/reference/html/project-features.html#features-wiremock
s

Shruti Mishra

05/07/2023, 8:07 AM
Hi @Bas Dijkstra I have been getting the same error from last few days, when trying to configure wiremock with Spring boot. "Request was not matched as there were no stubs registered:" As suggested, I have written only one testethod using wiremock server. wiremockserver.stubfor() Can you please sugggest some solution. Thanks
b

Bas Dijkstra

05/07/2023, 8:12 AM
Hi @Shruti Mishra , that’s very hard to do without actually seeing what your code looks like. I’d love to help out and have a look but I don’t think I’ve got a lot of time this coming week, but if you’re allowed to share your code (via GitHub or in another way) I’ll see what I can do. The solution is probably not too difficult but without looking at the code it’s going to be guesswork.
s

Shruti Mishra

05/07/2023, 10:07 AM
Untitled.java
Hi @Bas Dijkstra Please find the postman and eclipse error console.
b

Bas Dijkstra

05/07/2023, 10:18 AM
Thank you, I’ll try and have a look soon.
s

Shruti Mishra

05/07/2023, 10:34 AM
Thanks @Bas Dijkstra