Automated Unit Testing with ABAP : A Practical Approach
معرفی کتاب «Automated Unit Testing with ABAP : A Practical Approach» نوشتهٔ James E. McDonough (auth.)، منتشرشده توسط نشر Apress : Imprint: Apress در سال 2021. این کتاب در فرمت pdf، زبان انگلیسی ارائه شده است.
Write automated unit tests for the ABAP language. This book teaches programmers using simple examples and metaphors and explains the underlying concepts of writing effective automated unit tests. Many, if not most, ABAP programmers learned their programming and testing skills before the ABAP development environment provided an automated unit testing facility. Automated Unit Testing with ABAP: A Practical Approach offers hope and salvation to ABAP programmers who continue to toil with antiquated manual unit testing processes, taking them by the hand and lifting them out of that dungeon of despair with a modern and proven alternative. It begins by explaining how the xUnit family of automated testing frameworks provides a quick and effective means of insuring high-quality software. It then focuses on the ABAP Unit Testing Facility, the xUnit framework applicable specifically to the ABAP language, showing how it can be used to bring ABAP applications under automated testing control, from old legacy applications to those newly written. Whereas xUnit testing has been widely accepted with developers writing in many other programming languages, it is an unfortunate fact in the ABAP community that many programmers still are unfamiliar with xUnit concepts and do not know how to begin implementing automated unit testing into their development process. This book demonstrates how to refactor programs so they become designed for testability, showing how to use process encapsulation and test isolation to facilitate automated testing, including a thorough explanation of test-driven development and the use of test doubles. The book: Shows how to write automated unit tests for ABAP Instills ABAP programmers with the confidence to refactor poorly written code Explains how an automated testing harness facilitates rapid software development Teaches how to utilize test-driven development (TDD) with ABAP Offers advice and tips on the best ways to write automated unit tests What You Will Learn Become familiar with the xUnit approach to testing Know the ABAP statements that interfere with running automated unit tests and how to accommodate them Understand what it means to isolate code for testing and how this is achieved Gain the confidence to refactor poorly written code Make ABAP programs designed for testability Reap the benefits of spending less time manually unit testing ABAP programs Use test-driven development (TDD) with ABAP programming Use configurable test doubles in ABAP Who This Book Is For ABAP programmers who remain unfamiliar with the automated unit testing facility and those who already use it but want to improve their skill writing and using automated tests. The book addresses the reluctance and trepidation felt by procedural ABAP programmers who need to know some object-oriented concepts to use this facility, expands their horizons, and helps them step through the doorway leading to a different approach to program design. Table of Contents 5 About the Author 11 About the Technical Reviewer 12 Acknowledgments 13 Chapter 1: Introduction 14 For Whom This Book Is Applicable 14 How This Book Should Be Used 15 Why This Book Was Written 16 Credentials of the Author 19 Summary 20 Chapter 2: Preparing to Take the First Step 21 Road Map to Automated Unit Testing 21 Where We Are Now 22 Where We Are Going 23 Why We Are Going There 23 How We Are Going to Get There 25 Legacy Code 28 Calisthenics 29 Summary 30 Chapter 3: Software Quality 32 The Quality of Software 32 Assessing Software Quality 35 Summary 38 Chapter 4: The Origins of Automated Unit Testing 39 In the Beginning ... 39 The Emergence of xUnit 40 Features of xUnit 40 Phases of xUnit Tests 45 Writing xUnit Tests 46 Advantages of xUnit Tests 49 Summary 50 Quiz #1: xUnit Concepts 50 Multiple Choice: Select the Best Answer 51 True or False 52 Chapter 5: Automated Unit Testing with ABAP 53 ABAP Unit 53 The ABAP Unit Testing Framework 54 Requirements for Writing ABAP Unit Tests 56 Types of Components Applicable to Unit Testing 58 Testable ABAP Modularization Units 59 Automatic Generation of ABAP Unit Test Classes 61 ABAP Language Statements Related to Unit Testing 63 Writing an ABAP Unit Test 65 Using Fixture Methods 77 Invoking the Services of the ABAP Unit Testing Framework 81 ABAP Unit Test Runner 86 Unit Test Results Report 87 Initiating ABAP Unit Test Execution 89 Initiating Unit Tests from Within an ABAP Editor 89 Initiating Unit Tests from Outside an ABAP Editor 90 Evolution of the ABAP Unit Testing Framework 92 Challenges to Effectively Testing ABAP Code 93 Challenges Presented by Classic ABAP Event Blocks 94 Challenges Presented by Global Variables 94 Challenges Presented by the MESSAGE Statement 95 Challenges Presented by ALV Reports 97 Challenges Presented by Classic List Processing Statements 97 Challenges Presented by Open SQL Statements 99 Controlling the ABAP Unit Testing Framework 99 Client Category 99 Client Category Override 100 Unit Testing Configuration 101 Client Settings 104 Application Server Settings 104 Summary 105 Quiz #2: ABAP Unit Testing Concepts 106 Multiple Choice: Select the Best Answer 107 True or False 108 Chapter 6: Rudiments 109 Introducing a Simple Unit Test 109 Expanding Unit Test Coverage 113 Implementing Unit Tests for Function Modules 117 Implementing Unit Tests for Global Classes 118 ABAP Statements and Features Affecting Automated Unit Testing 120 Exploring the Effects of the MESSAGE Statement 120 Exploring the Effects of ALV Reports 125 Exploring the Effects of Classic List Processing Statements 129 How Automated Unit Testing Enables Confident Refactoring 132 Diagnosing the Absence of Sufficient Test Data 135 Creating and Using Fabricated Test Data 137 Gaining Control Over References to Modifiable Global Variables Within Subroutines 141 Summary 144 Chapter 7: Design for Testability 145 Changing the Production Path to Enable Automated Testing 145 Categorizing Input and Output 148 Encapsulating Indirect Input and Output 150 Interaction Points 153 Encapsulating Indirect Input Processes to Accommodate Unit Testing 159 Encapsulating Indirect Output Processes to Accommodate Unit Testing 163 Summary 168 Chapter 8: Test Doubles 169 Depended-On Components 169 The Purpose of Test Doubles 171 Alternative 1 173 Alternative 2 175 Alternative 3 176 Using Test Doubles 180 Test Double Using Base Class 181 Test Double Using Interface 191 Categories of Test Doubles 200 Using Test Doubles for Indirect Input 202 Using Test Doubles for Indirect Output 209 Summary 220 Chapter 9: Service Locator 221 Purpose of a Service Locator 221 Using a Service Locator 222 Using a Service Factory 236 Organizing Local Components 239 Summary 259 Chapter 10: Leveraging the Service Locator 260 Issues Requiring Leverage 260 Using the Service Locator to Manage Global Classes 262 Using the Service Locator to Manage Function Modules 264 Using the Service Locator to Manage MESSAGE Statements 270 Handling MESSAGE Statements Triggering Unconditional Unit Test Failures 271 Handling Unit Test Failures Arising from MESSAGE Statement Control Flow 283 Using the Service Locator to Manage List Processing Statements 297 Summary 313 Chapter 11: Test-Driven Development 314 The TDD Cycle 314 The Three Laws of TDD 315 The Benefits of TDD 317 Following the TDD Cycle 318 Summary 336 Chapter 12: Configurable Test Doubles 337 Isolation Frameworks 337 mockA 338 ABAP Test Double Framework 338 Summary 359 Chapter 13: Obtaining Code Coverage Information Through ABAP Unit Testing 360 Code Coverage Metrics 360 Summary 362 Chapter 14: Cultivating Good Test Writing Skills 363 The Pillars of Good Unit Tests 363 Test Simplicity 364 Test Coverage 366 SAP Recommendations and Constraints When Writing Unit Tests 367 Tips for Writing Unit Tests 368 Issues Related to Testing Object-Oriented Code 371 Summary 372 Chapter 15: Welcome to Autropolis 373 One Small Step for Manual Toward Automated 373 The Right Tool for the Job 374 Resistance Is Futile 375 Becoming the Agent for Change 376 Go Forth and Automate 377 Summary 377 Appendix A: Requirements Documentation and ABAP Exercise Programs 378 Appendix B: Answers to Chapter Quizzes 379 Answers to Quiz #1 379 Multiple Choice: Select the Best Answer 379 True or False 380 Answers to Quiz #2 381 Multiple Choice: Select the Best Answer 381 True or False 382 Appendix C: Concepts Associated with Defining Local Test Classes 384 Index 389
دانلود کتاب Automated Unit Testing with ABAP : A Practical Approach