- Wiremock Intro?
- Serves canned responses to particular requests (stubbing), and that captures incoming requests so that they can be checked later (verification).
- External to application code which helps in the testing app in Dev and ST(System Testing) environment
- Helps in testing negative Scenarios like network latency
- Language Agnostic and production like testing
- How to differentiate Positive and Negative Scenarios?
It could be done based on method(GET, POST, DELETE, PUT), Path(/employee, /success) and based on Parameter.GET /employee?name=mugil Method - GET Path - /employee Params - name
- How priority of Stub Response is selected when Paths overlap?
Stub is lowest no in priority would be selected.0102030405060708091011//Priority 1
wireMockServer.stubFor(get(
"/welcome"
)
.atPriority(
1
)
.willReturn(aResponse()
.withBody(
"Welcome with Priority 1"
)));
//Priority 2
wireMockServer.stubFor(get(
"/welcome"
)
.atPriority(
2
)
.willReturn(aResponse()
.withBody(
"Welcome with Priority 2"
)));
Output
Welcome with Priority 1
- What is advantage of using Wiremock as Standalone?
- Less dependency on Environment
- Useful for Load Testing
- Can be used by non JVM environment
- Can run remotely
- What are possible defects which could happen in application?
- Timeout
- Server Error
- Invalid Response