You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When migrating to JUnit 5. I have an idea to provide an annotation e.g. @PippoTest (extends JUnit @Test annotation) and provides a PippoTestClient instance.
Example:
@PippoTest
public void testEndpoint(PippoTestClient client) {
final var httpClient = HttpClient.newHttpClient(); // using official java.net.HttpClient
final var httpRequest = client.newRequestBuilder("/path").GET().build();
final var response = httpClient.send(httpRequest, HttpResponse.BodyHandlers.ofString()).body();
assertThat(response).isEqualTo(..);
}
In this case the user doesn't need to take care of e.g. http://host:port . And when providing the port then JUnit 5 parallelism can be done (otherwise we would able to verify only one test method due single port)
The port should be choosen automatically because you don't know which ports are free on public CI (e.g. Travis CI)
For this case it would be helpful when we can start Pippo with port = 0 which simply picks up the next free port (otherwise we need a dirty workaround to ensure the thread safety; how I resolved it can be seen here: method startPippo() on MockHttpDaemon ).
The @PippoTest may come with some values / settings. Feel free to reach out me if you want know more details.
Thanks for your sugestion. I think that actual approach with PippoTest (see http://www.pippo.ro/doc/testing.html) is more simple and intuitive. More then that, java.net.HttpClient is a new class that is available only in Java 11 (Pippo is based on Java 8). But the variant with HttpClient (Java new HTTP, Apache HTTP Components, OkHttp, ...) is a very good alternative.
No description provided.
The text was updated successfully, but these errors were encountered: