In project directory:
- MAC
$ ./gradlew clean build
- Windows
$ gradlew.bat clean build
Artifact is built into build/libs folder
java -jar <path-to>/toy-robot.jar
Spock framework is used for tests. Compared to JUnit, it removes boilerplate thanks to Groovy. The DSL supports BDD out of the box.
Data Driven Testing is heavily used in the test code. A data pipe, indicated by the left-shift (<<) operator, connects a data variable to a data provider. The data provider holds all values for the variable, one per iteration.
where:
a << [3, 7, 0]
b << [5, 0, 0]
c << [5, 7, 0]
Above block indicates that 3 data sets are provided:
1 - a = 3, b = 5, c = 5
2 - a = 7, b = 0, c = 7
3 - a = 5, b = 7, c = 0
This is helpful when testing same functionality against different data, especially for edge cases.
> PLACE 4,4,EAST
> REPORT
4,4,EAST
> MOVE
> REPORT
4,4,EAST
> PLACE 1,2,EAST
> MOVE
> MOVE
> LEFT
> MOVE
> REPORT
3,3,NORTH
> PLACE 3,2,NORTH
> MOVE
> RIGHT
> REPORT
3,3,EAST