Groovy
- no
do-while
Truth
Object
-
identity comparison
a.is(b)
-
value comparison
a.equals(b)
Class
@Immutable
: Define immutable class@Sortable
: Make classComparable
, implementingcompareTo
method based on the order of property definition, as well as correspondingComparator
helper methods.@TupleConstructor
: Create constructors with different combinations of properies as arguments
Collection
List
- Use list to replace array, in the case of array literal, use list literal instead, it will get converted automatically.
Map
- Map keys are strings by default:
[a:1]
is equivalent to['a':1]
- To use value of object
a
as the key, escape the key by adding parenthesis:[(a): 43]
equals to['Bob': 43]
Groovy Reference
- Groovy API (opens in a new tab)
- Groovy Documentation (opens in a new tab)
- Groovy Goodness (opens in a new tab)
Spock
Comparison to JUnit
Spock | JUnit |
---|---|
Specification | Test class |
setup() | @Before |
cleanup() | @After |
setupSpec() | @BeforeClass |
cleanupSpec() | @AfterClass |
Feature | Test |
Feature method | Test method |
Data-driven feature | Theory |
Condition | Assertion |
Exception condition | @Test(expected=…) |
Interaction | Mock expectation (e.g. in Mockito) |
Spock Reference
Geb
Notes
- property:
.@id
- text node:
.text()
Questions
- How to access iframe contents