ABAP Object Unit, 747 ABAP Unit, 747 Abstract Setup Decorator Defined, 449 Example, 453 Acceptance Tests. See Also Customer Test
Total Page:16
File Type:pdf, Size:1020Kb
Index A Hard-Coded Test Data solution, 196 ABAP Object Unit, 747 preface, xxi ABAP Unit, 747 anonymous inner class Abstract Setup Decorator defi ned, 786 defi ned, 449 Test Stub examples, 535–536 example, 453 Ant, 753 acceptance tests. See also AntHill, 753 customer tests anti-pattern (AP) defi ned, 785 defi ned, 786 why test?, 19 test smells, xxxv accessor methods, 785 AOP (aspect-oriented programming) ACID, 785 defi ned, 786 acknowledgements, xxvii–xxviii Dependency Injection, 681 action components, 280 retrofi tting testability, 148 agile method API (application programming inter- defi ned, 785–786 face) property tests, 52 Creation Methods, 416 AllTests Suite database as SUT, 336 example, 594–595 defi ned, 786 introduction, 13 Test Utility Method, 600 when to use, 593 architecture, design for testability. annotation See design-for-testability defi ned, 786 arguments Test Methods, 351 messages describing, 371–372 Anonymous Creation Method as parameters (Dummy defi ned, 417 Arguments), 729 example, 420 role-describing, 725 835 836 Index Arguments, Dummy, 729 improperly coded in Neverfail Ariane 5 rocket, 218 Tests, 274 aspect-oriented programming (AOP) introduction, 77 defi ned, 786 Missing Assertion Messages, Dependency Injection, 681 226–227 retrofi tting testability, 148 reducing Test Code Duplication, Assertion Message 114–119 of Assertion Method, 364 refactoring, xlvi–xlix pattern description, 370–372 Self-Checking Tests, 107–108 Assertion Method unit testing, 6 Assertion Messages, 364 Verify One Condition per Test, calling built-in, 363–364 46–47 choosing right, 364–365 assumptions, xxxix–xl Equality Assertions, 365 Astels, Dave, 110 examples, 368–369 asynchronous tests Expected Exception defi ned, 787 Assertions, 366 Hard-To-Test Code, 210–211 Fuzzy Equality Assertions, Humble Object, 696–697 365–366 Slow Tests, 255–256 implementation, 363 testability, 70–71 as macros, 364 Attachment Method motivating example, 367–368 defi ned, 418 overview, 362–363 example, 421 refactoring, 368 attributes Single-Outcome Assertions, defi ned, 787 366–367 dummy, 729 Stated Outcome Assertions, 366 hiding unnecessary, 303–304 Assertion Roulette One Bad Attribute. See One Eager Tests, 224–226 Bad Attribute impact, 224 parameters as, 608 introduction, 14 Suite Fixture Setup, 442–443 Missing Assertion Message, Test Discovery using, 397 226–227 Test Selection, 403–405 symptoms, 224 Automated Exercise Teardown assertions defi ned, 505 Built-in, 110–111 example, 508 custom. See Custom Assertion Automated Fixture Teardown, defi ned, 786 504–505 diagramming notation, xlii Automated Teardown Domain Assertions, 476, ensuring Repeatable Tests, 27 481–482 examples, 507–508 Index 837 implementation, 504–505 Beck, Kent, xxii Interacting Test Suites, 232 sniff test, xxxviii Interacting Tests solution, 231 Test Automation Frameworks, motivating example, 505–506 301 overview, 503–504 test smells, 9 of persistent fi xtures, 99–100 Testcase Class per Class, 618 refactoring, 506–507 xUnit, 57 resource leakage solution, 233 Behavior Sensitivity when to use, 504 cause of Fragile Tests, 242–243 automated unit testing caused by Overspecifi ed author’s motivation, xxiv–xxv Software, 246 fragile test problem, xxxi–xxxii defi ned, xxxi introduction, xxx–xxxii smells, 14 behavior smells, 223–247 B Assertion Roulette. See Assertion Roulette back door, defi ned, 787 defi ned, 10–11, 788 Back Door Manipulation Erratic Tests. See Erratic Test control/observation points, 66–67 Fragile Tests. See Fragile Test database as SUT API, 336 Frequent Debugging. See Expected State Specifi cation, 464 Frequent Debugging fi xture setup, 333–335 Manual Intervention. See implementation, 330–332 Manual Intervention motivating example, 332 overview, 13–15 overview, 327–328 Slow Tests. See Slow Tests refactoring, 333 Behavior Verifi cation setup, 329 approach to Self-Checking teardown, 330 Tests, 108 verifi cation, 329–330 examples, 472–473 verifi cation using Test Spy, 333 implementation, 469–471 when to use, 328 indirect outputs, 179–180 Back Door Setup motivating example, 471–472 controlling indirect inputs, 128 overview, 468–469 fi xture design, 59 refactoring, 472 Prebuilt Fixtures, 430–431 vs. state, 36 transient fi xtures, 86 test results, 112–114 Back Door Verifi cation, 130–133 using Mock Objects. See BDUF (big design upfront) Mock Object defi ned, 787 using Test Spies. See Test Spy design for testability, 65 using Use the Front Door test automation strategy, 49 First, 40 838 Index verifying indirect outputs, BPT (Business Process Testing) 130–133 defi ned, 753 when to use, 469 Recorded Tests, 280 behavior-driven development Test Automation defi ned, 787–788 Frameworks, 301 Testcase Class per Fixture Bug Repellent, 22 usage, 632 Buggy Test Behavior-Exposing Subclass introduction, 12–13 Test-Specifi c Subclass reducing risk, 181 example, 587 symptoms, 260–262 when to use, 580 Built-in Assertion Behavior-Modifying Subclass calling, 363–364 Defi ning Test-Specifi c Equality, introduction, 110–111 588–589 built-in self-tests Substituted Singleton, defi ned, 788 586–587 test fi le organization, 164 Test Stub, 584–585 built-in test recording when to use, 580 defi ned, 281 Bespoke Assertion. See Custom example, 281–282 Assertion business logic bimodal tests, 687 defi ned, 789 binding, static developer testing, xxx defi ned, 809 development process, 4–5 Dependency Injection, 678–679 Layer Tests example, 344–345 black box testing without databases, defi ned, 788 169–171 Remoted Stored Procedure Business Process Testing (BPT). Tests, 656 See BPT (Business Process Testing) block closures defi ned, 788 Expected Exception Tests, C 354–355 Calculated Value. See also Derived blocks Value cleaning up fi xture teardown Loop-Driven Tests, 615 logic, l–liv Production Logic in Test defi ned, 788 solution, 205 try/fi nally. See try/fi nally block Canoo WebTest boundary values defi ned, 753 defi ned, 788 Scripted Tests, 286 erratic tests, 238 Test Automation Minimal Fixtures, 303 Frameworks, 301 result verifi cation patterns, 478 test automation tools, 53 Index 839 capacity tests, 52 samples, xli–xlii Capture/Playback Test. writing tests, 27–29 See Recorded Test code smells Chained Test Conditional Test Logic. See customer testing, 6 Conditional Test Logic examples, 459–460 defi ned, 10–11, 789 implementation, 456–457 Hard-To-Test Code. See motivating example, 457–458 Hard-To-Test Code overview, 454–455 obscure tests. See Obscure Test refactoring, 458 Test Code Duplication. See Test Shared Fixture strategies, 64–65 Code Duplication Shared Fixtures, 104–105, 322 Test Logic in Production. See when to use, 455–456 Test Logic in Production xUnit introduction, 57 types of, 16–17 class attributes coding idioms defi ned, 789 defi ned, xxxv Test Discovery using, 397 design patterns, 792 Testcase Class Selection using, collisions 404–405 Interacting Tests, 229–231 class methods Shared Fixtures, 318 defi ned, 789 Command object with Test Helper, 645, 646 introduction, 82 class variables Testcase Object as, 382 defi ned, 789 Command-Line Test Runner Suite Fixture Setup, 442 Assertion Message, 371 classes defi ned, 379–380 diagramming notation, xlii introduction, 79 as fi xtures, 59 Missing Assertion Message, Test Double, 569–570, 572–573 226–227 Testcase. See Testcase Class commercial recorded tests class-instance duality, 374 refactored, 283–284 Cleanup Method, 602 tools, 282–283 closure, block common location, Test Discovery, defi ned, 788 397–398 Expected Exception Tests, Communicate Intent 354–355 defi ned, 41 Cockburn, Alistair refactoring Recorded Tests to, pattern naming, 578 283–284 service layer tests, 339 compiler macro, Test Method code Discovery, 395–396 inside-out development, 34–36 Complex Teardown, 206–207 organization. See test Complex Test. See Dependency organization Lookup 840 Index Component Broker. See Dependency Confi gurable Test Double Lookup examples, 564–567 Component Registry, 688 implementation, 559–562 component tests installing, 141–142 defi ned, 790 as kind of Test Double, 528 layer-crossing tests, 69 motivating example, 562–563 per-functionality, 52 overview, 558 test automation philosophies, refactoring, 563 34–36 when to use, 559 test strategy patterns, 340 Confi gurable Test Stub. See also components Confi gurable Test Double defi ned, 790 implementation, 532 depended-on component. See indirect input control, 179 DOC (depended-on Confi guration Interface component) examples, 564–566 Composite object, defi ned, 82 implementation, 560 Concerns, Separation of, 28–29 Confi guration Mode concrete classes, 581 example, 566–567 Condition Verifi cation Logic, 203–204 implementation, 560 Conditional Test Logic Constant Value. See Literal Value vs. Assertion Method, 363 constants in Derived Value, avoidance, 119–121 718–722 avoiding via Custom constructing Mock Object, 546 Assertion, 475 Constructor Injection avoiding via Guard Assertion, example, 683–684 490–493 implementation, 680–681 causes, 201–202 installing Test Doubles, 144 Complex Teardown, 206–207 Constructor Test Condition Verifi cation Logic, defi ned, 351 203–204 example, 355–357 Flexible Tests, 202–203 introduction, 77 impact, 201 constructors introduction, 16 defi ned, 790 Multiple Test Conditions, problems with, 419 207–208 containers, Humble Container Production Logic in Test, Adapter, 698 204–205 Context Sensitivity symptoms, 200 avoiding via Isolate the SUT, Test Methods, 155 43–44 Confi gurable Mock Object, 546–547. defi ned, 245–246 See also Confi gurable Test Double introduction, xxxii, 14 Confi gurable Registry, 691–692 continuous design, xxxiii Index 841 continuous integration CSV