Plack::Test::Agent is an OO interface to test PSGI applications. It can perform GET and POST requests against PSGI applications either in process or over HTTP through a Plack::Handler compatible backend.

The new constructor creates an instance of Plack::Test::Agent. This constructor takes one mandatory named argument and several optional arguments.

app is the mandatory argument. You must provide a PSGI application to test.

server is an optional argument. When provided, Plack::Test::Agent will attempt to start a PSGI handler and will communicate via HTTP to the application running through the handler. See Plack::Loader for details on selecting the appropriate server.

host is an optional argument representing the name or IP address for the server to use. The default is localhost.

port is an optional argument representing the TCP port to for the server to use. If not provided, the service will run on a randomly selected available port outside of the IANA reserved range. (See Test::TCP for details on the selection of the port number.)

ua is an optional argument of something which conforms to the LWP::UserAgent interface such that it provides a request method which takes an HTTP::Request object and returns an HTTP::Response object. The default is an instance of LWP::UserAgent.

This method takes a URI and makes a POST request against the PSGI application with that URI. It returns an HTTP::Response object representing the results of that request. As an optional second parameter, pass an array reference of key/value pairs for the form content: