It is not very clear from Spock documentation how to split Spock feature methods into multiple functions. But, for example, Geb test scenarios sometimes can be quite complicated (if you want to verify something across multiple pages) and worth extracting into multiple methods for clarity and reuse.
In practice, this is very simple and all you have to do is just extract method and define Java style asserts as it is in Spock documentation about helper classes. What is not in documentation, is that you can freely mix actions with validation in same method, so for example, you can do something like this:
At least this works fine with Geb.
In practice, this is very simple and all you have to do is just extract method and define Java style asserts as it is in Spock documentation about helper classes. What is not in documentation, is that you can freely mix actions with validation in same method, so for example, you can do something like this:
def "do something"() {
when:
someLink.click()
then:
validateEverything()
}
def validateEverything() {
menuLink1.click()
assert text1 == 'some text'
menuLink2.click()
assert text2 == 'other text'
}
At least this works fine with Geb.
No comments:
Post a Comment