Skip to Content
Test-driven Java development: invoke TDD principles for end-to-end application development with Java

Test-driven Java development: invoke TDD principles for end-to-end application development with Java

Farcic, Viktor, author; Garcia, Alex (Computer programmer), author

"Test-driven development (TDD) is a development approach that relies on a test-first procedure that emphasises writing a test before writing the necessary code, and then refactoring the code to optimize it. The value of performing TDD with Java, one of the most established programming languages, is to improve the productivity of programmers, the maintainability and performance of code, and develop a deeper understanding of the language and how to employ it effectively. Starting with the basics of TDD and reasons why its adoption is beneficial, this book will take you from the first steps of TDD with Java until you are confident enough to embrace the practice in your day-to-day routine. You'll be guided through setting up tools, frameworks, and the environment you need, and will dive right in to hands-on exercises with the goal of mastering one practice, tool, or framework at a time. You'll learn about the Red-Green-Refactor procedure, how to write unit tests, and how to use them as executable documentation. With this book you'll also discover how to design simple and easily maintainable code, work with mocks, utilise behaviour-driven development, refactor old legacy code, and release a half-finished feature to production with feature toggles. You will finish this book with a deep understanding of the test-driven development methodology and the confidence to apply it to application programming with Java"--Provided by publisher

eBook, Paperback, Electronic resource, Book. English. Electronic books.
Published Birmingham ; Mumbai : Packt Publishing 2015
Rate this

This resource is available electronically from the following locations


Statement of responsibility: Viktor Farcic, Alex Garcia
ISBN: 178398743X, 9781783987429, 9781783987436
Note: Includes index.
Note: Print version record.
Physical Description: 1 online resource (258 pages) : illustrations
Series: Community experience distilled
Subject: Application software Development.; COMPUTERS Programming Languages JavaScript.; Application software Testing.; Java (Computer program language)
Alternative Title: Invoke TDD principles for end-to-end application development with Java
Series Title: Community experience distilled.
Local note: eBooks on EBSCOhost EBSCO eBooks for FE Collection (UK)


  1. Cover
  2. Copyright
  3. Credits
  4. About the Authors
  5. About the Reviewers
  7. Table of Contents
  8. Preface
  9. Chapter 1: Why Should I Care for Test-driven Development?
  10. Why TDD?
  11. Understanding TDD
  12. Red-green-refactor
  13. Speed is the key
  14. It's not about testing
  15. Testing
  16. The black-box testing
  17. The white-box testing
  18. The difference between quality checking and quality assurance
  19. Better tests
  20. Mocking
  21. Executable documentation
  22. No debugging
  23. Summary
  24. Chapter 2 : Tools, Frameworks, and EnvironmentsGit
  25. Virtual machines
  26. Vagrant
  27. Docker
  28. Build tools
  29. The integrated development environment
  30. The IDEA demo project
  31. Unit testing frameworks
  32. JUnit
  33. TestNG
  34. Hamcrest and AssertJ
  35. Hamcrest
  36. AssertJ
  37. Code coverage tools
  38. JaCoCo
  39. Mocking frameworks
  40. Mockito
  41. EasyMock
  42. Extra power for mocks
  43. User interface testing
  44. Web testing frameworks
  45. Selenium
  46. Selenide
  47. The behavior-driven development
  48. JBehave
  49. Cucumber
  50. Summary
  51. Chapter 3 : Red-Green-Refactor
  52. from Failure through Success until Perfection Setting up the environment with Gradle and JUnit
  53. Setting up Gradle/Java project in IntelliJ IDEA
  54. The red-green-refactor process
  55. Write a test
  56. Run all the tests and confirm that the last one is failing
  57. Write the implementation code
  58. Run all the tests
  59. Refactor
  60. Repeat
  61. The Tic-Tac-Toe game requirements
  62. Developing Tic-Tac-Toe
  63. Requirement 1
  64. Test
  65. Implementation
  66. Test
  67. Implementation
  68. Test
  69. Implementation
  70. Refactoring
  71. Requirement 2Test
  72. Implementation
  73. Test
  74. Implementation
  75. Test
  76. Requirement 3
  77. Test
  78. Implementation
  79. Test
  80. Implementation
  81. Refactoring
  82. Test
  83. Implementation
  84. Test
  85. Implementation
  86. Test
  87. Implementation
  88. Refactoring
  89. Requirement 4
  90. Test
  91. Implementation
  92. Refactoring
  93. Code coverage
  94. More exercises
  95. Summary
  96. Chapter 4 : Unit Testing
  97. Focusing on What You Do and Not on What Has Been Done
  98. Unit testing
  99. What is unit testing?
  100. Why unit testing?
  101. Code refactoring
  102. Why not use unit tests exclusively?Unit testing with TDD
  103. TestNG
  104. The @Test annotation
  105. The @BeforeSuite, @BeforeTest, @BeforeGroups, @AfterGroups, @AfterTest, and @AfterSuite annotations
  106. The @BeforeClass and @AfterClass annotations
  107. The @BeforeMethod and @AfterMethod annotations
  108. The @Test(enable = false) annotation argument
  109. The @Test(expectedExceptions = SomeClass.class) annotation argument
  110. TestNG vs JUnit summary
  111. Remote controlled ship requirements
  112. Developing the remote-controlled ship
  113. Project setup
  114. Helper classes