Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/chemyl/wire_mocking
https://github.com/chemyl/wire_mocking
Last synced: 19 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/chemyl/wire_mocking
- Owner: chemyl
- Created: 2023-12-15T13:48:31.000Z (about 1 year ago)
- Default Branch: master
- Last Pushed: 2023-12-15T13:48:52.000Z (about 1 year ago)
- Last Synced: 2023-12-18T09:48:09.122Z (about 1 year ago)
- Language: Java
- Size: 2.93 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
## Mock API
For testing purpose when using production integration is impossible.
Complex services with obtaining test dataSUT App send request to Mock-Service and get static **preconfigured** response.
- Fake it until you make it;
- Simulate APIs that don't exist yet
- SetUp happy Path response;
- SetUp negative Path response;
- Create stable isolated test environment;
- Test flaky 3rd parties;
- Test unstable or complex-data services;Mockito / PowerMock => create complex Java object within unit test;
WireMock => setting up stable test environment;### 2 ways to create stub:
- 1- register stub from WireMock instance by **register()** method; | setting up more than one stub
- 2- use static DSL chain methods within **stubFor()** method; | only one stub possible### InMemoryMock
InMemoryMock - work in test environment in current Java thread;
* Set Up one or more Mock Service
@RegisterExtension
static WireMockExtension wireMockExtension = new WireMockExtension .Builder().options(options().port(8080)).build();* create @BeforeEach method with configuration of the stub
### StandaloneMock
StandAloneMock - work within Java thread, from Docker run.
* Crete JsonStub file with preconditions
* Up and Run WireMock image in Docker by **docker.mock.yaml**
* set volumes -> JsonStub file
* set ports* For more details visit - https://wiremock.org/docs/