Prosper



Prosper

0 0


prosper-presentation


On Github lykorian / prosper-presentation

Prosper

AEM integration testing made Spockier.

M. Daugherty

Questions?

Goals

  • Better test coverage for components, servlets, and services
  • Eliminate OSGi container dependency, but provide a JCR for repository-based testing
  • Use a pre-1.0 testing framework

No Excuses

Because there's always a reason to avoid writing tests.

  • Easy to integrate into existing Maven projects
  • Extensive documentation and examples (by hobby project standards)
  • API designed to minimize boilerplate for common tasks
  • Elegant specification syntax

About Spock

Spock Syntax

                        class DataDriven extends Specification {
    def "maximum of two numbers"() {
        expect:
        Math.max(a, b) == c

        where:
        a | b || c
        3 | 5 || 5
        7 | 0 || 7
        0 | 0 || 0
    }
}
                    

Features

  • Transient repository for running tests in the standard Maven lifecycle
  • Basic implementations of Sling dependencies
  • Builders for creating content and mocking complex requests/responses
  • Assertions for verifying JCR state
  • Ability to add Sling adapters on-the-fly
  • Support for testing JSP tag classes

Bedrock

  • Additional builder for ComponentRequest with ability to register OSGi services
  • Sightly support for AEM6

In Action

class BreadcrumbSpec extends ComponentSpec {

    def setupSpec() {
        pageBuilder.content {
            home("Home") {
                "jcr:content" {
                    breadcrumb(delineator: "-")
                }
                products("Products") {
                    tools("Tools") {
                        "jcr:content" {
                            breadcrumb(rootPage: "/content/home")
                        }
                    }
                }
            }
        }
    }

    def "get delineator"() {
        setup:
        def request = componentRequestBuilder.build {
            path = "/content/home/jcr:content/breadcrumb"
        }

        def breadcrumb = new Breadcrumb(request)

        expect:
        breadcrumb.delineator == "-"
    }

    def "get links"() {
        setup:
        def request = componentRequestBuilder.build {
            path = "/content/home/products/tools/jcr:content/breadcrumb"
        }

        def breadcrumb = new Breadcrumb(request)
        def links = breadcrumb.links

        expect:
        links.size() == 3
        links*.title == ["Home", "Products", "Tools"]
    }
}

Future

  • Sightly support

Contribute

Questions?

“Go forth and Prosper.”