Test-driven Java development: invoke TDD principles for end-to-end application development
Gespeichert in:
Hauptverfasser: | , |
---|---|
Format: | Buch |
Sprache: | English |
Veröffentlicht: |
Birmingham, UK
Packt Publishing
2018
|
Ausgabe: | Second edition |
Schlagworte: | |
Online-Zugang: | Inhaltsverzeichnis |
Beschreibung: | ix, 306 Seiten illustrations |
ISBN: | 9781788836111 |
Internformat
MARC
LEADER | 00000nam a2200000zc 4500 | ||
---|---|---|---|
001 | BV045179204 | ||
003 | DE-604 | ||
005 | 20181130 | ||
007 | t | ||
008 | 180911s2018 a||| |||| 00||| eng d | ||
020 | |a 9781788836111 |9 978-1-78883-611-1 | ||
035 | |a (OCoLC)1057661240 | ||
035 | |a (DE-599)BVBBV045179204 | ||
040 | |a DE-604 |b ger |e rda | ||
041 | 0 | |a eng | |
049 | |a DE-739 | ||
084 | |a ST 250 |0 (DE-625)143626: |2 rvk | ||
100 | 1 | |a Garcia, Alex |e Verfasser |4 aut | |
245 | 1 | 0 | |a Test-driven Java development |b invoke TDD principles for end-to-end application development |c Alex Garcia, Viktor Farcic |
250 | |a Second edition | ||
264 | 1 | |a Birmingham, UK |b Packt Publishing |c 2018 | |
300 | |a ix, 306 Seiten |b illustrations | ||
336 | |b txt |2 rdacontent | ||
337 | |b n |2 rdamedia | ||
338 | |b nc |2 rdacarrier | ||
650 | 4 | |a Application software |x Testing | |
650 | 4 | |a Application software |x Development | |
650 | 4 | |a Java (Computer program language) | |
650 | 0 | 7 | |a Java |g Programmiersprache |0 (DE-588)4401313-9 |2 gnd |9 rswk-swf |
650 | 0 | 7 | |a Test-First-Ansatz |0 (DE-588)4674451-4 |2 gnd |9 rswk-swf |
689 | 0 | 0 | |a Java |g Programmiersprache |0 (DE-588)4401313-9 |D s |
689 | 0 | 1 | |a Test-First-Ansatz |0 (DE-588)4674451-4 |D s |
689 | 0 | |5 DE-604 | |
700 | 1 | |a Farcic, Viktor |0 (DE-588)1121699731 |4 aut | |
776 | 0 | 8 | |i Erscheint auch als |n Online-Ausgabe |z 1-78883-212-4 |
856 | 4 | 2 | |m Digitalisierung UB Passau - ADAM Catalogue Enrichment |q application/pdf |u http://bvbr.bib-bvb.de:8991/F?func=service&doc_library=BVB01&local_base=BVB01&doc_number=030568429&sequence=000002&line_number=0001&func_code=DB_RECORDS&service_type=MEDIA |3 Inhaltsverzeichnis |
999 | |a oai:aleph.bib-bvb.de:BVB01-030568429 |
Datensatz im Suchindex
_version_ | 1804178870438461440 |
---|---|
adam_text | Table of Contents
Preface_______________________________________________________________
Chapter 1: Why Should I Care for Test-Driven Development? 7
Why TDD? 8
Understanding TDD 9
Red-Green-Refactor 9
Speed is the key 11
It s not about testing 12
Testing 12
Black-box testing 12
White-box testing 13
The difference between quality checking and quality assurance 14
Better tests 15
Mocking 15
Executable documentation 16
No debugging 18
Summary 19
Chapter 2: Tools, Frameworks, and Environments 21
Git 22
Virtual machines 22
Vagrant 23
Docker 25
Build tools 26
The integrated development environment 28
The IDEA demo project 29
Unit-testing frameworks 30
JUnit 31
TestNG 33
Hamcrest and AssertJ 35
Hamcrest 36
AssertJ 37
Table of Contents
Code coverage tools 38
JaCoCo 38
Mocking frameworks 39
Mockito 42
EasyMock 44
Extra power for mocks 46
User interface testing 46
Web-testing frameworks 46
Selenium 47
Selenide 48
Behavior-driven development so
JBehave so
Cucumber 53
Summary 55
Chapter 3: Red-Green-Refactor - From Failure Through Success until
Perfection 57
Setting up the environment with Gradle and JUnit 58
Setting up Gradle/Java project in IntelliJ IDEA 58
The Red-Green-Refactor process 61
Writing a test 62
Running all the tests and confirming that the last one is failing 62
Writing the implementation code 62
Running all the tests 63
Refactoring 63
Repeating 63
Tic-Tac-Toe game requirements 64
Developing Tic-Tac-Toe 64
Requirement 1 - placing pieces 65
Test - board boundaries I 68
Implementation 69
Test - board boundaries II 69
Implementation 70
Test - occupied spot 70
Implementation 71
Refactoring 71
Requirement 2 - adding two-player support 72
Table of Contents
Test-X plays first 73
Implementation 74
Test - 0 plays right after X 74
Implementation 74
Test-X plays right after O 75
Requirement 3 - adding winning conditions 75
Test - by default there s no winner 76
Implementation 76
Test-winning condition I 76
Implementation 77
Refactoring 77
Test - winning condition II 78
Implementation 79
Test - winning condition III 79
Implementation 80
Test - winning condition IV 80
Implementation 81
Refactoring 81
Requirement 4 - tie conditions 82
Test - handling a tie situation 82
Implementation 83
Refactoring 83
Code coverage 84
More exercises 86
Summary 86
Chapter 4: Unit Testing - Focusing on What You Do and Not on What
Has Been Done 87
Unit testing 88
What is unit testing? 88
Why unit testing? 89
Code refactoring 89
Why not use unit tests exclusively? 89
Unit testing with TDD 91
TestNG 92
The @Test annotation 92
The @BeforeSuite, @BeforeTest, @BeforeGroups, @AfterGroups,
@AfterTest, and @AfterSuite annotations 93
------------------------------------- [iii] ---------------------------------------
Table of Contents
The @BeforeClass and @AfterClass annotations 94
The @BeforeMethod and @AfterMethod annotations 94
The @Test(enable = false) annotation argument 94
The @Test(expectedExceptions = SomeClass.class) annotation argument 94
TestNG versus JUnit summary 94
Remote-controlled ship requirements 95
Developing the remote-controlled ship 96
Project setup 96
Helper classes 98
Requirement - starting point and orientation 99
Specification - keeping position and direction in memory 100
Implementation 101
Refactoring 101
Requirement - forward and backward moves 102
Specification - moving forward 102
Implementation 104
Specification - moving backward 104
Implementation 105
Requirement - rotating the ship 105
Specification - turning left 105
Implementation 106
Specification - turning right 106
Implementation 106
Requirement - commands 106
Specification - single commands 107
Implementation 107
Specification - combined commands 109
Implementation 109
Requirement - representing spheric maps 110
Specification - planet information 111
Implementation 111
Refactoring 112
Specification - dealing with map boundaries 113
Implementation 113
Requirement - detecting obstacles 114
Summary 115
Chapter 5: Design - If It s Not Testable, It s Not Designed Well 117
-------------------------------------- [ iv ] --------------------------------------
Table of Contents
Why should we care about design? 118
Design principles 118
You Ain t Gonna Need It 118
Don t Repeat Yourself 119
Keep it simple, stupid 119
Occam s razor 119
SOLID principles 120
Connect 4 121
Requirements 121
Test-last implementation of Connect 4 122
Requirement 1 - the game s board 122
Requirement 2 - introducing discs 123
Requirement 3 - player shifts 124
Requirement 4 - the game s output 125
Requirement 5 - win conditions (I) 126
Requirement 6 - win condition (II) 127
Requirement 7 - win condition (III) 128
Requirement 8 - win condition (IV) 129
The TDD or test-first implementation 130
Hamcrest 130
Requirement 1 - the game s board 131
Requirement 2 - introducing discs 132
Requirement 3 - player shifts 134
Requirement 4 - the game s output 135
Requirement 5 - win condition (I) 137
Requirement 6 - win condition (II) 137
Requirement 7 - win condition (III) 138
Requirement 8 - win condition (IV) 139
Final considerations 140
Summary 141
Chapter 6: Mocking - Removing External Dependencies 143
Mocking 144
Why mocks? 145
Terminology 145
Mock objects 146
---------------------------------- [v] -----------------------------------
Table of Contents
Mockito 147
Tic-Tac-Toe v2 requirements 147
Developing Tic-Tac-Toe v2 148
Requirement 1 - store moves 149
Specification - DB name 150
Implementation 150
Specification - a name for the Mongo collection 151
Implementation 151
Refactoring 151
Specification - adding items to the Mongo collection 153
Implementation 155
Specification - adding operation feedback 157
Implementation 157
Refactoring 157
Specification - error handling 158
Implementation 159
Specification - clear state between games 159
Implementation 160
Specification - drop operation feedback 160
Implementation 160
Specification - error handling 160
Implementation 161
Requirement 2 - store every turn 161
Specification - creating new collection 162
Implementation 162
Specification refactoring 163
Specification - storing current move 163
Implementation 164
Specification - error handling 165
Implementation 166
Specification - alternate players 166
Implementation 167
Exercises 167
Integration tests 168
Tests separation 168
The integration test 169
Summary 172
[vi]
Table of Contents
Chapter 7: TDD and Functional Programming - A Perfect Match 173
Setting up the environment 174
Optional - dealing with uncertainty 174
Example of Optional 175
Functions revisited 178
Kata - Reverse Polish Notation 179
Requirements 179
Requirement-handling invalid input 180
Requirement - single operations 181
Requirement - complex operations 183
Streams 185
filter 185
map 186
flatMap 186
reduce 187
Summary 188
Chapter 8: BDD - Working Together with the Whole Team 189
Different specifications 190
Documentation 191
Documentation for coders 192
Documentation for non-coders 193
Behavior-driven development 193
Narrative 194
Scenarios 195
The book store BDD story 197
J Behave 201
JBehave runner 201
Pending steps 202
Selenium and Selenide 204
JBehave steps 205
Final validation 211
Summary 213
Chapter 9: Refactoring Legacy Code - Making It Young Again 215
Legacy code 216
Legacy code example 217
---------------------------------- [vii] ----------------------------------
Table of Contents
Other ways to recognize legacy code 220
A lack of dependency injection 221
The legacy code change algorithm 222
Applying the legacy code change algorithm 222
Identifying change points 222
Finding test points 223
Breaking dependencies 224
Writing tests 226
The kata exercise 227
Legacy kata 227
Description 227
Technical comments 228
Adding a new feature 228
Black-box or spike testing 228
Preliminary investigation 229
How to find candidates for refactoring 231
Introducing the new feature 232
Applying the legacy code algorithm 232
Writing end-to-end test cases 233
Automating the test cases 237
Injecting the BookRepository dependency 239
Extract and override call 239
Parameterizing a constructor 241
Adding a new feature 242
Removing the primitive obsession with status as int 244
Summary 248
Chapter 10: Feature Toggles - Deploying Partially Done Features to
Production 249
Continuous integration, delivery, and deployment 250
Feature Toggles 252
A Feature Toggle example 253
Implementing the Fibonacci service 257
Working with the template engine 260
Summary 264
Chapter 11: Putting It All Together 267
TDD in a nutshell 268
[ viii ]
Table of Contents
Best practices 269
Naming conventions 270
Processes 272
Development practices 274
Tools 278
Summary 279
Chapter 12: Leverage TDD by Implementing Continuous Delivery 281
Case study - Awesome Gambling Corp 282
Exploring the codebase 282
Release procedure 285
Deployments to production 286
Conclusions 287
Possible improvements 288
Increasing test coverage 288
Implementing continuous integration 289
Towards continuous delivery 289
Jenkins installation 290
Automating builds 293
First execution 296
What is next? 297
This is just the beginning 298
This does not have to be the end 298
Summary 298
Other Books You May Enjoy_______________________________________________299
Index 303
[ix]
|
any_adam_object | 1 |
author | Garcia, Alex Farcic, Viktor |
author_GND | (DE-588)1121699731 |
author_facet | Garcia, Alex Farcic, Viktor |
author_role | aut aut |
author_sort | Garcia, Alex |
author_variant | a g ag v f vf |
building | Verbundindex |
bvnumber | BV045179204 |
classification_rvk | ST 250 |
ctrlnum | (OCoLC)1057661240 (DE-599)BVBBV045179204 |
discipline | Informatik |
edition | Second edition |
format | Book |
fullrecord | <?xml version="1.0" encoding="UTF-8"?><collection xmlns="http://www.loc.gov/MARC21/slim"><record><leader>01696nam a2200409zc 4500</leader><controlfield tag="001">BV045179204</controlfield><controlfield tag="003">DE-604</controlfield><controlfield tag="005">20181130 </controlfield><controlfield tag="007">t</controlfield><controlfield tag="008">180911s2018 a||| |||| 00||| eng d</controlfield><datafield tag="020" ind1=" " ind2=" "><subfield code="a">9781788836111</subfield><subfield code="9">978-1-78883-611-1</subfield></datafield><datafield tag="035" ind1=" " ind2=" "><subfield code="a">(OCoLC)1057661240</subfield></datafield><datafield tag="035" ind1=" " ind2=" "><subfield code="a">(DE-599)BVBBV045179204</subfield></datafield><datafield tag="040" ind1=" " ind2=" "><subfield code="a">DE-604</subfield><subfield code="b">ger</subfield><subfield code="e">rda</subfield></datafield><datafield tag="041" ind1="0" ind2=" "><subfield code="a">eng</subfield></datafield><datafield tag="049" ind1=" " ind2=" "><subfield code="a">DE-739</subfield></datafield><datafield tag="084" ind1=" " ind2=" "><subfield code="a">ST 250</subfield><subfield code="0">(DE-625)143626:</subfield><subfield code="2">rvk</subfield></datafield><datafield tag="100" ind1="1" ind2=" "><subfield code="a">Garcia, Alex</subfield><subfield code="e">Verfasser</subfield><subfield code="4">aut</subfield></datafield><datafield tag="245" ind1="1" ind2="0"><subfield code="a">Test-driven Java development</subfield><subfield code="b">invoke TDD principles for end-to-end application development</subfield><subfield code="c">Alex Garcia, Viktor Farcic</subfield></datafield><datafield tag="250" ind1=" " ind2=" "><subfield code="a">Second edition</subfield></datafield><datafield tag="264" ind1=" " ind2="1"><subfield code="a">Birmingham, UK</subfield><subfield code="b">Packt Publishing</subfield><subfield code="c">2018</subfield></datafield><datafield tag="300" ind1=" " ind2=" "><subfield code="a">ix, 306 Seiten</subfield><subfield code="b">illustrations</subfield></datafield><datafield tag="336" ind1=" " ind2=" "><subfield code="b">txt</subfield><subfield code="2">rdacontent</subfield></datafield><datafield tag="337" ind1=" " ind2=" "><subfield code="b">n</subfield><subfield code="2">rdamedia</subfield></datafield><datafield tag="338" ind1=" " ind2=" "><subfield code="b">nc</subfield><subfield code="2">rdacarrier</subfield></datafield><datafield tag="650" ind1=" " ind2="4"><subfield code="a">Application software</subfield><subfield code="x">Testing</subfield></datafield><datafield tag="650" ind1=" " ind2="4"><subfield code="a">Application software</subfield><subfield code="x">Development</subfield></datafield><datafield tag="650" ind1=" " ind2="4"><subfield code="a">Java (Computer program language)</subfield></datafield><datafield tag="650" ind1="0" ind2="7"><subfield code="a">Java</subfield><subfield code="g">Programmiersprache</subfield><subfield code="0">(DE-588)4401313-9</subfield><subfield code="2">gnd</subfield><subfield code="9">rswk-swf</subfield></datafield><datafield tag="650" ind1="0" ind2="7"><subfield code="a">Test-First-Ansatz</subfield><subfield code="0">(DE-588)4674451-4</subfield><subfield code="2">gnd</subfield><subfield code="9">rswk-swf</subfield></datafield><datafield tag="689" ind1="0" ind2="0"><subfield code="a">Java</subfield><subfield code="g">Programmiersprache</subfield><subfield code="0">(DE-588)4401313-9</subfield><subfield code="D">s</subfield></datafield><datafield tag="689" ind1="0" ind2="1"><subfield code="a">Test-First-Ansatz</subfield><subfield code="0">(DE-588)4674451-4</subfield><subfield code="D">s</subfield></datafield><datafield tag="689" ind1="0" ind2=" "><subfield code="5">DE-604</subfield></datafield><datafield tag="700" ind1="1" ind2=" "><subfield code="a">Farcic, Viktor</subfield><subfield code="0">(DE-588)1121699731</subfield><subfield code="4">aut</subfield></datafield><datafield tag="776" ind1="0" ind2="8"><subfield code="i">Erscheint auch als</subfield><subfield code="n">Online-Ausgabe</subfield><subfield code="z">1-78883-212-4</subfield></datafield><datafield tag="856" ind1="4" ind2="2"><subfield code="m">Digitalisierung UB Passau - ADAM Catalogue Enrichment</subfield><subfield code="q">application/pdf</subfield><subfield code="u">http://bvbr.bib-bvb.de:8991/F?func=service&doc_library=BVB01&local_base=BVB01&doc_number=030568429&sequence=000002&line_number=0001&func_code=DB_RECORDS&service_type=MEDIA</subfield><subfield code="3">Inhaltsverzeichnis</subfield></datafield><datafield tag="999" ind1=" " ind2=" "><subfield code="a">oai:aleph.bib-bvb.de:BVB01-030568429</subfield></datafield></record></collection> |
id | DE-604.BV045179204 |
illustrated | Illustrated |
indexdate | 2024-07-10T08:10:50Z |
institution | BVB |
isbn | 9781788836111 |
language | English |
oai_aleph_id | oai:aleph.bib-bvb.de:BVB01-030568429 |
oclc_num | 1057661240 |
open_access_boolean | |
owner | DE-739 |
owner_facet | DE-739 |
physical | ix, 306 Seiten illustrations |
publishDate | 2018 |
publishDateSearch | 2018 |
publishDateSort | 2018 |
publisher | Packt Publishing |
record_format | marc |
spelling | Garcia, Alex Verfasser aut Test-driven Java development invoke TDD principles for end-to-end application development Alex Garcia, Viktor Farcic Second edition Birmingham, UK Packt Publishing 2018 ix, 306 Seiten illustrations txt rdacontent n rdamedia nc rdacarrier Application software Testing Application software Development Java (Computer program language) Java Programmiersprache (DE-588)4401313-9 gnd rswk-swf Test-First-Ansatz (DE-588)4674451-4 gnd rswk-swf Java Programmiersprache (DE-588)4401313-9 s Test-First-Ansatz (DE-588)4674451-4 s DE-604 Farcic, Viktor (DE-588)1121699731 aut Erscheint auch als Online-Ausgabe 1-78883-212-4 Digitalisierung UB Passau - ADAM Catalogue Enrichment application/pdf http://bvbr.bib-bvb.de:8991/F?func=service&doc_library=BVB01&local_base=BVB01&doc_number=030568429&sequence=000002&line_number=0001&func_code=DB_RECORDS&service_type=MEDIA Inhaltsverzeichnis |
spellingShingle | Garcia, Alex Farcic, Viktor Test-driven Java development invoke TDD principles for end-to-end application development Application software Testing Application software Development Java (Computer program language) Java Programmiersprache (DE-588)4401313-9 gnd Test-First-Ansatz (DE-588)4674451-4 gnd |
subject_GND | (DE-588)4401313-9 (DE-588)4674451-4 |
title | Test-driven Java development invoke TDD principles for end-to-end application development |
title_auth | Test-driven Java development invoke TDD principles for end-to-end application development |
title_exact_search | Test-driven Java development invoke TDD principles for end-to-end application development |
title_full | Test-driven Java development invoke TDD principles for end-to-end application development Alex Garcia, Viktor Farcic |
title_fullStr | Test-driven Java development invoke TDD principles for end-to-end application development Alex Garcia, Viktor Farcic |
title_full_unstemmed | Test-driven Java development invoke TDD principles for end-to-end application development Alex Garcia, Viktor Farcic |
title_short | Test-driven Java development |
title_sort | test driven java development invoke tdd principles for end to end application development |
title_sub | invoke TDD principles for end-to-end application development |
topic | Application software Testing Application software Development Java (Computer program language) Java Programmiersprache (DE-588)4401313-9 gnd Test-First-Ansatz (DE-588)4674451-4 gnd |
topic_facet | Application software Testing Application software Development Java (Computer program language) Java Programmiersprache Test-First-Ansatz |
url | http://bvbr.bib-bvb.de:8991/F?func=service&doc_library=BVB01&local_base=BVB01&doc_number=030568429&sequence=000002&line_number=0001&func_code=DB_RECORDS&service_type=MEDIA |
work_keys_str_mv | AT garciaalex testdrivenjavadevelopmentinvoketddprinciplesforendtoendapplicationdevelopment AT farcicviktor testdrivenjavadevelopmentinvoketddprinciplesforendtoendapplicationdevelopment |