Dissecting PlaySpecification
The tests written using Specs2 can also be written as follows:
class UtilSpec extends PlaySpecification {...}
PlaySpecification is a trait that provides the required helper methods to test a Play application using Specs2. It is defined as:
trait PlaySpecification extends Specification
with NoTimeConversions
with PlayRunners
with HeaderNames
with Status
with HttpProtocol
with DefaultAwaitTimeout
with ResultExtractors
with Writeables
with RouteInvokers
with FutureAwaits {
}Let's scan through the API exposed by each of these traits to understand its significance:
SpecificationandNoTimeConversionsare traits of Specs2.NoTimeConversionscan be used to deactivate the time conversions.PlayRunnersprovides helper methods to execute a block of code in a running application or server with or without specifying the browser.HeaderNamesandStatusdefine constants for all the standard HTTP headers and HTTP status codes, respectively...