Executed features | Passed | Failures | Errors | Skipped | Success rate | Time |
---|---|---|---|---|---|---|
5 | 5 | 0 | 0 | 0 | 100.0% | 0.050 seconds |
Surface interface
Component test for static methods of Surface interface
should precisely calculate area of square surface
Return
(0)
|
|||||||||||||||||||||||||||||
When:
|
def square = Surface.square(side) |
||||||||||||||||||||||||||||
Then:
|
square instanceof Surface |
||||||||||||||||||||||||||||
And:
|
square.area() == areaOfSquare |
||||||||||||||||||||||||||||
Examples:
|
|
4/4 passed
|
|||||||||||||||||||||||||||
should precisely calculate area of rectangle surface
Return
(0)
|
|||||||||||||||||||||||||||||
When:
|
def rectangle = Surface.rectangle(a, b) |
||||||||||||||||||||||||||||
Then:
|
rectangle instanceof Surface |
||||||||||||||||||||||||||||
And:
|
rectangle.area() == areaOfRectangle |
||||||||||||||||||||||||||||
Examples:
|
|
6/6 passed
|
|||||||||||||||||||||||||||
should throw an exception for the negative or zero side of the square
Return
(0)
|
|||||||||||||||||||||||||||||
When:
|
def square = Surface.square(side) |
||||||||||||||||||||||||||||
Then:
|
def message = thrown(IllegalArgumentException) |
||||||||||||||||||||||||||||
And:
|
message =~ "must be a positive" |
||||||||||||||||||||||||||||
Examples:
|
|
4/4 passed
|
|||||||||||||||||||||||||||
should throw an exception for the negative or zero sides of the rectangle
Return
(0)
|
|||||||||||||||||||||||||||||
When:
|
def rectangle = Surface.rectangle(width, height) |
||||||||||||||||||||||||||||
Then:
|
def message = thrown(IllegalArgumentException) |
||||||||||||||||||||||||||||
And:
|
message =~ "must be a positive" |
||||||||||||||||||||||||||||
Examples:
|
|
6/6 passed
|
|||||||||||||||||||||||||||
should subtract one surfaces from other
Return
(0.008 seconds)
|
|||||||||||||||||||||||||||||
Given:
|
def totalSurface = Spy(Surface) { area() >> totalArea } def apertures = Spy(Surface) { area() >> aperturesArea } |
||||||||||||||||||||||||||||
When:
|
def result = totalSurface - apertures |
||||||||||||||||||||||||||||
Then:
|
result.area() == expectedArea |
||||||||||||||||||||||||||||
Examples:
|
|
2/2 passed
|