jeudi 11 octobre 2018

WireMock: different mapping for each test

I would like to set different mappings for each test using WireMock.

I'm totally new to WireMock and I need to do it quickly. I need something like:

@Test
public void test1() {
  // some logic here
}

@Test
public void test2() {
  // some logic here as well
}

And different mapping for each method like:

mappings/test1.json:

{
  "request": {
    "method": "GET",
    "url": "/some/thing"
  },
  "response": {
    "status": 200,
    "body": "Hello world!",
    "headers": {
      "Content-Type": "text/plain"
    }
  }
}

mappings/test2.json:

{
  "request": {
    "method": "GET",
    "url": "/some/thing"
  },
  "response": {
    "status": 404
  }
}

How can I achieve this using WireMock?

I know I might be able to find some solutions across the internet, but I need to do it quickly, so I asking you for help, may be urls to tutorial on how to do this.

Aucun commentaire:

Enregistrer un commentaire