In GEB I started utilizing static "content" with my assertions.
Here's how it works. My tests have been getting messy. Lots of assertions stacked into the tests. So to clean it up a bit, I was advised by a developer here, to put the assertions into the page object's static content.
In the page object, we have this:
In between the brackets we can define the assertions for this page, like this:
Now, in the test, I can reference these assertions like this:
This makes the test itself look clean and more human readable.
Here's how it works. My tests have been getting messy. Lots of assertions stacked into the tests. So to clean it up a bit, I was advised by a developer here, to put the assertions into the page object's static content.
In the page object, we have this:
static content = {
}
In between the brackets we can define the assertions for this page, like this:
static content = {
basicsOccupation {$("td.header", 0)}
basicsAge {$("td.header", 1)}
basicsAge {$("td.header", 1)}
}
Now, in the test, I can reference these assertions like this:
then: "All page elements load without problem"
basicsOccupation.text().equals("Occupation:")
basicsAge.text().equals("Age:")
basicsOccupation.text().equals("Occupation:")
basicsAge.text().equals("Age:")
This makes the test itself look clean and more human readable.
No comments:
Post a Comment