Fork me on GitHub
#pedestal
<
2023-05-02
>
kpav15:05:25

I am going through the http://pedestal.io/guides/pedestal-with-component#using-pedestal-with-component doc, and theres a bit in there about not starting the server when testing, but it doesn't really explain the "why" -- I am curious why we would not want the server to start while unit testing?

hlship18:05:53

It's not very clear in the doc; essentially, starting up Jetty and routing requests through it is somewhat slow, and there's also the issue of the port - which can only be bound by a single thread. Pedestal includes code that uses the application stack, minus the actual HTTP processing part (Jetty), and allows you to exercise it without involving HTTP - you send data to routes, it goes through all the appropriate interceptors and handlers, and you can validate the response against expectations. This is less brittle and much faster for testing.

hlship18:05:14

I'm having some trouble getting doc updates published, but I'll look into updating this to be more clear.

👍 3
👏 1
kpav14:05:41

Thanks again for the insightful answer! It makes a lot of sense, and it makes me appreciate the fact that you can test routes and interceptors separately from the server, gives a lot of flexibility in testing