title: Reusing tests from one HTTP client to another
body: <p>I wrote a simple library in Java that converts HTTP requests from one library (REST-assured) to curl commands. Surprisingly, there were many corner cases of HTTP protocol that I had to support. That led to creating quite a nice suite of tests.</p>
  <p>Now I would like to provide support for another format of HTTP requests (Apache HTTP client).</p>
  <p>I would like to reuse existing tests to drive development because on abstract level tests would use same HTTP requests that I used for REST-assured. However, the difference would be in their representation:</p>
  <pre><code>Some abstract HTTP request -&gt; RestAssuredRequest -&gt; library -&gt; curl command
  
  Some abstract HTTP request -&gt; Apache HttpRequest -&gt; library -&gt; curl command
  </code></pre>
  <p>In other word, to reuse same tests, I would need first to define some common representation for HTTP request and then converters from this representation to specific HTTP client. Seems like a bit of over-engineering, probably error-prone logic that I would use only in tests. There is already something like that, called <a href="https://github.com/googleapis/google-http-java-client" rel="nofollow noreferrer">Google HTTP client</a> that is a wrapper over popular HTTP clients, although it does not support REST-assured, which means I would need to provide a support for that.</p>
  <p>Am I doomed to the solution where I repeat same tests for each HTTP client I want to support?</p>
  <p>Or there is third solution?</p>