Diese Präsentation wurde erfolgreich gemeldet.
Wir verwenden Ihre LinkedIn Profilangaben und Informationen zu Ihren Aktivitäten, um Anzeigen zu personalisieren und Ihnen relevantere Inhalte anzuzeigen. Sie können Ihre Anzeigeneinstellungen jederzeit ändern.
Groovy Unit Testing By Franz See [email_address] http://twitter.com/franz_see
Agenda I. Review Basics A. Parts B. Organization II. Groovy Test
Review Basics :: Parts @RunWith(Suite.class) @Suite.SuiteClasses([..]) class GameBoardTests { static class Move_Validation...
Review Basics :: Parts @Test void givenValidMove_shouldMarkLocation() { int x = 1, y = 3 gameBoard.move(x, y) assertEquals...
Review Basics :: Parts @Test void givenValidMove_shouldMarkLocation() { int x = 1, y = 3 assertThat "[GUARD] Makes su...
Review Basics :: Organization A. Test by Class B. Test by Feature C. Test by Fixture
Review Basics :: Organization :: by Class @RunWith(Suite.class) class GameBoardTests { @Test( expected = IllegalMoveExcept...
Review Basics :: Organization :: by Feature @RunWith(Suite.class) @Suite.SuiteClasses([..]) class GameBoardTests { static ...
Review Basics :: Organization :: by Fixture @RunWith(Suite.class) @Suite.SuiteClasses([..]) class GameBoardTests { static ...
Groovy Test (see code)
Thank you. Questions?
References <ul><li>Xunit Test Patterns
Nächste SlideShare
Wird geladen in …5
×

Testing in-groovy

1.029 Aufrufe

Veröffentlicht am

Groovy Unit Testing

Veröffentlicht in: Technologie, Business
  • Als Erste(r) kommentieren

  • Gehören Sie zu den Ersten, denen das gefällt!

Testing in-groovy

  1. 1. Groovy Unit Testing By Franz See [email_address] http://twitter.com/franz_see
  2. 2. Agenda I. Review Basics A. Parts B. Organization II. Groovy Test
  3. 3. Review Basics :: Parts @RunWith(Suite.class) @Suite.SuiteClasses([..]) class GameBoardTests { static class Move_Validation extends GivenGameBoard { @Test( expected = IllegalMoveException.class ) void givenXIsBelow1() { } @Test( expected = IllegalMoveException.class ) void givenXIsAbove3() { } ... } static class Move_Marking extends GivenGameBoard { @Test void givenValidMove_shouldMarkLocation() { } @Test void givenValidMoves_shouldMarkLocations() { } } ... }
  4. 4. Review Basics :: Parts @Test void givenValidMove_shouldMarkLocation() { int x = 1, y = 3 gameBoard.move(x, y) assertEquals &quot;Should have been marked 'X' after the move.&quot;, X, gameBoard.getCells()[y-1][x-1] }
  5. 5. Review Basics :: Parts @Test void givenValidMove_shouldMarkLocation() { int x = 1, y = 3 assertThat &quot;[GUARD] Makes sure that it is not 'X' ' + 'before the move.&quot;, gameBoard.getCells()[y-1][x-1], not(equalTo(X)) gameBoard.move(x, y) assertEquals &quot;Should have been marked 'X' after the move.&quot;, X, gameBoard.getCells()[y-1][x-1] }
  6. 6. Review Basics :: Organization A. Test by Class B. Test by Feature C. Test by Fixture
  7. 7. Review Basics :: Organization :: by Class @RunWith(Suite.class) class GameBoardTests { @Test( expected = IllegalMoveException.class ) void givenXIsBelow1_whenMove_then _thenComplain () {…} @Test( expected = IllegalMoveException.class ) void givenXIsAbove3_whenMove_thenComplain() {…} @Test void givenValidMove_whenMove_shouldMarkLocation() {…} @Test void givenValidMoves_ whennMove_ shouldMarkLocations() {…} }
  8. 8. Review Basics :: Organization :: by Feature @RunWith(Suite.class) @Suite.SuiteClasses([..]) class GameBoardTests { static class Move { @Test( expected = IllegalMoveException.class ) void givenXIsBelow1_then_thenComplain() {…} @Test( expected = IllegalMoveException.class ) void givenXIsAbove3_thenComplain() {…} @Test void givenValidMove_shouldMarkLocation() {…} @Test void givenValidMoves_shouldMarkLocations() {…} } }
  9. 9. Review Basics :: Organization :: by Fixture @RunWith(Suite.class) @Suite.SuiteClasses([..]) class GameBoardTests { static class GivenXIsBelow1 { @Test( expected = IllegalMoveException.class ) void thenComplain() {…} } static class GivenXIsAbove3 { @Test( expected = IllegalMoveException.class ) void thenComplain() {…} } static class GivenValidMove { @Test void shouldMarkLocation() {…} @Test void shouldMarkLocations() {…} } }
  10. 10. Groovy Test (see code)
  11. 11. Thank you. Questions?
  12. 12. References <ul><li>Xunit Test Patterns
  13. 13. Working Effectively with Legacy Code
  14. 14. http://www.mockobjects.com/
  15. 15. http://tech.groups.yahoo.com/group/testdrivendevelopment/
  16. 16. http://sites.google.com/site/tddproblems/
  17. 17. http://code.google.com/p/tic-tac-toe-tdd/
  18. 18. http://code.google.com/p/appfuse-top-to-bottom-tdd/ </li></ul>

×