Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The assert keyword is optional in 'expect:'  or 'then:' blocks. Groovy will automatically 'assert' any Boolean expression in these blocks.
Depending on the complexity of the expression and the amount of code in this block it might help to highlight what is being asserted using the 'assert' keyword. It is also a mater of personal choice this convention does not enforce either approach.  

Current findings is that assertions are sometimes refactored into separate code blocks (methods or closures) and the DO NEED to use the assert keyword! But that often gets forgotten then and tets seems to pass but the assertions are no longer being checked and can lead to future false positives. To prevent this it is now recommended to always use the assert keyword.

In the example above above we couldshould have used

Code Block
languagegroovy
titleExpect and Labels Example
	expect: 'the outbound request XML contains the default rop period of "FIFTEEN_MIN"'
		assert activateEventJobRequest.getRequest(eventHeaders).contains("<reportingPeriod>FIFTEEN_MIN</reportingPeriod>")

...