Skip to content

Commit

Permalink
add a note about tests failing because of HTTP connection caching in …
Browse files Browse the repository at this point in the history
…the HTTP client #342
  • Loading branch information
Ronald Holshausen committed Dec 20, 2017
1 parent 79890f1 commit 54d8a27
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pact-jvm-consumer-groovy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,13 @@ PactVerificationResult result = alice_service.runTest() { mockServer ->
}
```

### Note on HTTP clients and persistent connections

Some HTTP clients may keep the connection open, based on the live connections settings or if they use a connection cache. This could
cause your tests to fail if the client you are testing lives longer than an individual test, as the mock server will be started
and shutdown for each test. This will result in the HTTP client connection cache having invalid connections. For an example of this where
the there was a failure for every second test, see [Issue #342](https://github.com/DiUS/pact-jvm/issues/342).

### Body DSL

For building JSON bodies there is a `PactBodyBuilder` that provides as DSL that includes matching with regular expressions
Expand Down
7 changes: 7 additions & 0 deletions pact-jvm-consumer-junit/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,13 @@ For example:

For an example test that uses these, have a look at [PactProviderWithMultipleFragmentsTest](src/test/java/au/com/dius/pact/consumer/pactproviderrule/PactProviderWithMultipleFragmentsTest.java)

### Note on HTTP clients and persistent connections

Some HTTP clients may keep the connection open, based on the live connections settings or if they use a connection cache. This could
cause your tests to fail if the client you are testing lives longer than an individual test, as the mock server will be started
and shutdown for each test. This will result in the HTTP client connection cache having invalid connections. For an example of this where
the there was a failure for every second test, see [Issue #342](https://github.com/DiUS/pact-jvm/issues/342).

### Using the Pact DSL directly

Sometimes it is not convenient to use the ConsumerPactTest as it only allows one test per test class. The DSL can be
Expand Down

0 comments on commit 54d8a27

Please sign in to comment.