bsideup / testcontainers-microservices-example

http://testcontainers.org
8 stars 3 forks source link

mockserver callbacks #1

Open glebsts opened 6 years ago

glebsts commented 6 years ago

@bsideup have you tried mockserver callback functionality? (dynamic building of responses). http://www.mock-server.com/mock_server/creating_expectations.html#callback

works by loading class from classpath by full name. Meaning class must be present in mockserver container.

Any thoughts on dynamic inclusion of compiled classes from test suite into container? I consider inventing some monster now, as I definitely want to build responses based on request fields, so I need callback classes for it. Ofc debugging won't be possible anyway, if we copy class into container... Or I'm going in wrong direction?

bsideup commented 6 years ago

@glebsts there are some mocking solutions with Groovy support so that you can send a callback as a Groovy script :)

bsideup commented 6 years ago

Check @glebsts https://github.com/TouK/http-mock-server for instance

bsideup commented 6 years ago

it's also possible and trivial to add Groovy support for the Mock Server BTW :)

glebsts commented 6 years ago

I'm afraid I need something more complicated. I.e. I want to publish messages to MQ before giving response, etc. Will think about using mockserver not from container, but from test class itself.. which means I need to map ports to externals from in-docker http client app and rmq consumer app. thnx,

bsideup commented 6 years ago

@glebsts I would recommend not to publish anything (or perform any other side effects) from the mock server! Yes, publishing from your tests is a preferred approach because it allows you to control what you do and when