Robot Test Cases
Setting | Value |
---|---|
Library | MonopolyLibrary |
Test Case | Action | IN: rounds | IN: Players | Post Condition: Actual Rounds | Post Condition: All Pieces Current Square | Post Condition: game Stop | Post Condition: Output Trace |
---|---|---|---|---|---|---|---|
Test1 | Run The Game And Check Post Conditions | ${2} | ${2} | ${2} | NOT goSquare | TRUE | NOT NULL |
Test2 | Run The Game And Check Post Conditions | ${17} | ${2} | ${17} | TRUE | NOT NULL |
Keyword | Action | Argument | Argument | Argument | Argument | Argument | Argument |
---|---|---|---|---|---|---|---|
Run The Game And Check Post Conditions | [Arguments] | ${rounds} | ${players} | ${actual rounds} | ${all pieces current square} | ${game stop} | ${output trace} |
Init The Game | ${rounds} | ${players} | |||||
Run The Game | |||||||
${testReturn} | Get Actual Rounds | ||||||
Should Be Equal | ${actualRounds} | ${testReturn} |


* Communication Diagram models the interactions between objects or parts in terms of sequenced messages.
It always worth reflection / inspiration from other models, e.g. activity diagram, system sequence diagram and so on. I haven’t took the picture, but if you could see all those on the wall clearly and clustered, you’ll fell the amaze.
* Class Diagram is a type of static structure diagram that describes the structure of a system by showing the system’s classes, their attributes, and the relationships between the classes.
Ok! Time for coding now!
Project is not essential, the reason we used is three people were in a group, we need a way to share, notebook screen was too small.
The pair proceeded according to ATDD cycle, have a failed acceptance test, start to design, write a failed unit test, fill in code to satisfy the failed unit test, refactor when needed, and so on.
A fairly good thing was having the "design wall" close to pair programming notebook, whenever there was some new ideas or abnormal signals from code, we discussed and updated either the design or the code, keep them up-to-understanding. Very frequent updates happened all along this pair session, we quickly draw our design on the wall, and update or even erase it totally and draw a new one. The erasable plastic paper was really great, without any tapes, it could be pasted on the wall just by the power of static (static electricity?).
Finally here were some unit tests and code for your reference :
* BoardTest.java
package monopoly;
import static org.junit.Assert.assertEquals;
import org.junit.Before;
import org.junit.Test;
public class BoardTest {
private Board board;
@Before
public void setUp() {
board = new Board();
}
@Test
public void startsFromSquareOne() throws Exception {
Square square = board.getStartingSquare();
assertEquals("1", square.getName());
}
@Test
public void movesToNextSquareAccordingToFaceValue() throws Exception {
Square startingSquare = board.getStartingSquare();
Square nextSquare = board.getNewSquare(startingSquare, 1);
assertEquals("2", nextSquare.getName());
nextSquare = board.getNewSquare(startingSquare, 7);
assertEquals("8", nextSquare.getName());
}
@Test
public void willPassStartingSquareAfterFullBoardRound() throws Exception {
Square currentSquare = board.getStartingSquare();
for (int i = 0; i < 4; i++) {
currentSquare = board.getNewSquare(currentSquare, 12);
}
assertEquals("9", currentSquare.getName());
}
}
* Board.java
package monopoly;
public class Board {
private static final int MAX_NUMBER_OF_SQUARES = 40;
public Square getNewSquare(final Square currentSquare, final int dieFaceValue) {
int nextNumber = calculateNextSquare(currentSquare, dieFaceValue);
return createSquare(nextNumber);
}
public Square getStartingSquare() {
return createSquare(1);
}
private Square createSquare(int nextNumber) {
return new Square("" + nextNumber);
}
private int calculateNextSquare(final Square currentSquare, final int dieFaceValue) {
int nextNumber = handleCircumnambulation(Integer.parseInt(currentSquare.getName()) + dieFaceValue);
return nextNumber;
}
private int handleCircumnambulation(int nextNumber) {
if (nextNumber > MAX_NUMBER_OF_SQUARES) {
nextNumber -= MAX_NUMBER_OF_SQUARES;
}
return nextNumber;
}
}
References :
– Experience comes from the workshop facilitated by Craig Larman, his website is www.craiglarman.com.
– Explanation of many terms come from www.wikipedia.org.
– Test Automation framework used is robotframework.
– Programming tool used is eclipse.
you’ll learn it via inspect and adapt 🙂
but this series is great
o, the picture is blur, and the craft is difficult to recognize, so i can only get some basic concept.