Peter Gfader's brain noise
Nice code - Usage of fluent interfaces - Java code

Seen in a test that searches for products

aProduct(“LAB-1234”
.named(“Labrador Retriever”)
  aProduct(“CHE-5678”)
.named(“Chesapeake”)
.describedAs(“Chesapeake bay retriever”)

   aProduct()
.named(“Dalmatian”)

Creates 3 products with the specified features.

The whole test looks like this

    @Test public void
    searchesAndFindsProductsInCatalog() {
        context.given(aProduct(“LAB-1234”).named(“Labrador Retriever”),
                aProduct(“CHE-5678”).named(“Chesapeake”).describedAs(“Chesapeake bay retriever”),
                aProduct().named(“Dalmatian”));
        petstore.searchFor(“retriever”);
        petstore.displaysNumberOfResults(2);
        petstore.displaysProduct(“LAB-1234”, “Labrador Retriever”);
        petstore.displaysProduct(“CHE-5678”, “Chesapeake”);
    }

Read all the code here

https://github.com/testinfected/petstore/blob/master/petstore-system-tests/src/test/java/test/system/com/pyxis/petstore/SearchFeature.java

Blog comments powered by Disqus