Upload
ebengtso
View
232
Download
5
Embed Size (px)
Citation preview
ABAP202
Dynamic Testing Throughout the ABAP Development Lifecycle
© SAP AG 2004, SAP TechEd / ABAP202 / 2
Contributing Speaker(s)
NameJonathan Maidstone, SAP AG
NameJürgen Staader, SAP AG
Motivation
Activatable Assertions & Breakpoints
ABAP Unit
GUI Scripting
eCATT
Summary
Motivation
Activatable Assertions & Breakpoints
ABAP Unit
GUI Scripting
eCATT
Summary
© SAP AG 2004, SAP TechEd / ABAP202 / 5
V-Model: Test Type Association
© SAP AG 2004, SAP TechEd / ABAP202 / 6
Advantages of Test Automation
Test automation
Saves time
Prevents human error during testing
Provides easily repeatable tests
Test automation during development
Reduces the number of bugs in programs
Provides developers with a regression test
Test automation during implementation or upgrade
Allows controlled repetition of complex scenarios using different sets of data
© SAP AG 2004, SAP TechEd / ABAP202 / 7
Test Tool Scope
Motivation
Activatable Assertions & Breakpoints
ABAP Unit
GUI Scripting
eCATT
Summary
© SAP AG 2004, SAP TechEd / ABAP202 / 9
Activatable Assertions & Breakpoints
Activatable Assertions and Breakpoints is a new technology in ABAP which
introduces the ASSERT statement and
extends the BREAK-POINT statement
It is useful for the development and the maintenance phase.
© SAP AG 2004, SAP TechEd / ABAP202 / 10
Activatable Checkpoints
Breakpoints are usually inactive. They can be centrally activated and provide expert knowledge where debugging should start for support and maintenance.
Assertions are used to guarantee the consistent state of the program control flow. They are typically active in development systems. They can be deactivated in production systems which runstably to avoid unnecessary check operations.
© SAP AG 2004, SAP TechEd / ABAP202 / 11
Distinctive test type characteristics
TraditionalTest Tools
Test creation effort needed
Performed in dedicated testexecution
Providing all kinds of situations –sound and strange situations
ActivatableAssertions & Breakpoints
No noteworthy effort to set them
Performed in ordinary production execution
Protection against unhealthysituations
© SAP AG 2004, SAP TechEd / ABAP202 / 12
Motivation for Activatable Breakpoints
Developers make explicit where breakpoints help to analyze their coding
Better than an informal comment use thespecial statement, a breakpoint that can be activated
some_code.* suggestion: start debugging here to inspect…more_code.
some_code.BREAK-POINT ID inspect_XYZ.more_code.
© SAP AG 2004, SAP TechEd / ABAP202 / 13
Motivation for Assertions
To write correct and maintainable programs…… make your assumptions and intentions explicit
Better than an informal comment use thespecial statement, the assertion
some_code.* the following condition should hold: v < 300000more_code.
some_code.ASSERT v < 300000. " nothing is faster than lightmore_code.
© SAP AG 2004, SAP TechEd / ABAP202 / 14
Benefits During Development and Tests
yste
m s
tate
program flow
consistent state
no
rmal
ter
min
atio
n
© SAP AG 2004, SAP TechEd / ABAP202 / 15
Benefits During Development and Tests
yste
m s
tate
program flow
consistent state
no
rmal
ter
min
atio
n
unexpected behavior
© SAP AG 2004, SAP TechEd / ABAP202 / 16
Benefits During Development and Tests
yste
m s
tate
program flow
consistent state
no
rmal
ter
min
atio
n
: assertion
runtime error
find error cause in shorter time
© SAP AG 2004, SAP TechEd / ABAP202 / 17
Assertion and Breakpoint Syntax
The checkpoint group group is a workbench object which is maintained using the transaction SAAB
ASSERT ID groupCONDITION cond
BREAK-POINTID group
with activation
ASSERT condBREAK-POINTalways active
conditional(Assertions)
unconditional(Breakpoints)Checkpoints
© SAP AG 2004, SAP TechEd / ABAP202 / 18
Activatable Assertions & Breakpoints Summary
Developers persist their expert knowledge about ideal debugging entries by inserting activatable breakpoints.
Developers cement their assumptions and intentions in the code by inserting assertions.
Assertions support developers in writing correct code. Possible errors are found early and are easily located.
Code instrumented with checkpoints is easier to support and maintain.
ABAP assertions can be activated on the fly and without program recompilation. They can be restricted to users or servers in order to take full advantage within production customer systems.
Motivation
Activatable Assertions & Breakpoints
ABAP Unit
GUI Scripting
eCATT
Summary
© SAP AG 2004, SAP TechEd / ABAP202 / 20
Test Single Units Before Assembling the Whole
© SAP AG 2004, SAP TechEd / ABAP202 / 21
Definitions
What is a Unit?
A unit is a non-trivial, accessible code portion where a given input or action causes a verifiable effect.
What is a Unit Test?
A unit test is the test which tests such a unit individually apart from all other units.
What is ABAP Unit?
ABAP Unit is the new test tool which allows developers writing and executing unit tests in ABAP.
© SAP AG 2004, SAP TechEd / ABAP202 / 22
Why are unit tests important?
Unit tests are development tests par excellence.
Testing begins early have confidence in your coding at any time
testing over longer period will increase program quality
reduce risk of bad surprises in the final testing phase
Bugs are found early correction is comparably cheap
project members work on better code base and become more productive
Bugs are found on small units easy error locating
Tests give additional information about the program
No extensive initial training neededtesting in familiar language and environment
© SAP AG 2004, SAP TechEd / ABAP202 / 23
The Tricky Relationship Between Developers and Testing
Testing is Boring
I Don’t Have Time to Test
I Test Already
Yes, but you like writing programs! ABAP Unit testing means writing programs in ABAP
that will do automatic testing for you!
That’s because you’re always fixing bugs. Write more tests, find more bugs more quickly!
OK, but your private test objects don’t conform to any standards,cannot be integrated into common QA processes,
do not provide automatic or regression testing.
© SAP AG 2004, SAP TechEd / ABAP202 / 24
ABAP Unit Load Concepts
Traditionally:
Code and test code separated
Test Code
Code
Load Test Load
Compilation
Load and execute
Load and execute
Load
Compilation
Load and execute
Test Code
Code
ABAP Unit:
Code and test code in ONE program
LoadTest Load
Load and execute
Prod.Env.
© SAP AG 2004, SAP TechEd / ABAP202 / 25
ABAP Unit Test Organization
© SAP AG 2004, SAP TechEd / ABAP202 / 26
Example – ABAP Unit Test Class Definition
class wallet_test definition for testing.
private section.
methods:
test for testing.
endclass.
© SAP AG 2004, SAP TechEd / ABAP202 / 27
Example – Test Class Definition
class wallet_test definition for testing.
private section.
methods:
test for testing.
endclass.
Identify class as test class
Identify method as test method
© SAP AG 2004, SAP TechEd / ABAP202 / 28
Example – Test Class Implementation
class wallet_test implementation.
method test.
create object wallet.
wallet->put_in( dollar = '12.50' ).
cl_aunit_assert=>assert_equals(
act = wallet->liquidity
exp = '12.50'
msg = ‚where‘s the difference?' ).
endmethod.
endclass.
Test code
Verify Test Assertion
© SAP AG 2004, SAP TechEd / ABAP202 / 29
Demo
Demo
© SAP AG 2004, SAP TechEd / ABAP202 / 30
ABAP Unit Summary
Standard Unit Test Value
Ensure the intended behaviour of the basic parts before building the whole
A substantial element of software quality assurance:Significantly improves the software development process
Significantly improves the software maintenance process
ABAP Unit Test Enhancements
Close integration into language
Keep code and tests synchronized
Equal weight on individual testing and on mass testing
Motivation
Activatable Assertions & Breakpoints
ABAP Unit
GUI Scripting
eCATT
Summary
© SAP AG 2004, SAP TechEd / ABAP202 / 32
SAP GUI Scripting
SAP GUI Scripting…...is an interface exposed by SAP GUI.
…can make life easier for users by automating repeating tasks.
…is a basis for tools that test the SAP system.
…allows client side applications to collaborate.
Availability:Shipped with SAP GUI 6.20 and future versions
Compatible with:All R/3 versions currently supported by SAP
Applications built on top of Web AS 6.10 to 6.40
Non-Dynpro based applications (BSP, Web Dynpro, …) are not supported. See note 587202 for known limitations.
© SAP AG 2004, SAP TechEd / ABAP202 / 33
Built-in Scripting Utilities in SAP GUI
© SAP AG 2004, SAP TechEd / ABAP202 / 34
SAP GUI Scripting Object Model
© SAP AG 2004, SAP TechEd / ABAP202 / 35
Platform and Programming Language Independence
Common Object Model for SAP GUI for Windows andSAP GUI for Java
The same types of objects are exposed
Same set of properties and methods
The runtime hierarchy is identical
Some differences in accessing the root object and the lifetime of event handlers
Result: Identical JavaScript scripts may be executedusing either SAP GUI for Java or SAP GUI for Windows
© SAP AG 2004, SAP TechEd / ABAP202 / 36
Testing Applications Using SAP GUI Scripting
Advantages
Quick record and replay to check that an application still works
No previous knowledge required for creating simple scripts
Private test objects stored locally on your workstation
Disadvantages
Requires VBS or Java Script knowledge to edit the script
No built-in mechanisms for handling pass/fail criteria
No higher-level management tools
© SAP AG 2004, SAP TechEd / ABAP202 / 37
Building on SAP GUI Scripting. . .
SAP GUI Scripting is used by various partner products, such as
Mercury Interactive
QuickTest Professional
LoadRunner
Compuware
TestPartner
QALoad
It is also used by SAP as one of the underlying technologies of the Extended Computer Aided Test Tool (eCATT)
Motivation
Activatable Assertions & Breakpoints
ABAP Unit
GUI Scripting
eCATT
Summary
© SAP AG 2004, SAP TechEd / ABAP202 / 39
ABAP Unit and eCATT: Key Differences
ABAP Unit
Accompanies development
White-box testing
Tests written
By the developer
In the ABAP Workbench
In ABAP
Tests attached to and transported with the object under test
Test execution always local
eCATT
Post-development or in upgrade
Gray-box testing
Tests written:
By a test automation expert
In the eCATT environment
Using eCATT script language
Tests not attached to the object under test, and are generally stored centrally
Test execution generally remote
© SAP AG 2004, SAP TechEd / ABAP202 / 40
Test Coverage with SAP eCATT
SAP Database
Read or check database tables
Check or activate Customizing settings in BC Sets
Application Server
Call function modules
Instantiate and test classes
Write ad-hoc ABAP routines in test scripts
Record and replay transactions running in SAPGUI for Windows and SAPGUI for Java
Record and replay Web Dynpro applications
Integrate certified external tools for testing otherdesktop or browser-based applications
© SAP AG 2004, SAP TechEd / ABAP202 / 41
Example: Possible Scope of an eCATT Test
Check that Customizing settings are correct
Run a transaction
Check the contents of an output field on the screen
Ensure that a particular message was sent
Pass a value from the last transaction to a different script that calls the next transaction in the business process
© SAP AG 2004, SAP TechEd / ABAP202 / 42
Structure of an eCATT Script
Recordan
Application
Field Checks
Mes
sag
e C
he
cks
Customizing Checks
Datab
ase Ch
ecks
Parameters
Define whatgoes in
Parameters
Define whatcomes out
© SAP AG 2004, SAP TechEd / ABAP202 / 43
Scripts: Building Blocks for Complex Tests
Script
Script
Script
Script
Script
Pool of test modules
Script Script Script
“High-level” scriptTests a business process by calling other scripts
© SAP AG 2004, SAP TechEd / ABAP202 / 44
Complicating the Issue – Multiple Test Systems
Test case must be ableto cross system boundarieseasily and must be portableto other system landscapes
© SAP AG 2004, SAP TechEd / ABAP202 / 45
eCATT System Landscape
Existing System Landscape
R/34.6C
CRM3.0
BW2.2 APO
3.1
Web AS 6.40(or higher)
eCATT Remote testing
SolutionManager(ProjectAdmin)
© SAP AG 2004, SAP TechEd / ABAP202 / 46
System Data Container – Your Test Landscape
© SAP AG 2004, SAP TechEd / ABAP202 / 47
eCATT Script Editor – Key Features At-A-Glance
Pattern insertion
Automatic parameter creation
Global search
Where-used list
Debugger
Start options controlling execution behavior
© SAP AG 2004, SAP TechEd / ABAP202 / 48
Demo
Demo
© SAP AG 2004, SAP TechEd / ABAP202 / 49
One Step Further … Data-Driven Tests
A test case must be able to be run repeatedly with different sets of data
But…
You cannot store multiple sets of data within a test script
So. . .
In order to create a data-driven test, you use a different test object called a test configuration
© SAP AG 2004, SAP TechEd / ABAP202 / 50
Test Configuration
Building a Data-Driven Test
Test Script
Commands
Logical Systems(unresolved)
Importing parameters(what data is required?)
+System Data Container
Resolves logical system namesinto real RFC destinations
+Variants
Each variant contains a valuefor each importing parameter
of the script
© SAP AG 2004, SAP TechEd / ABAP202 / 51
Where Do Variants Come From?
Design Time
Entered manually in configuration editor
Uploaded from an external file
Reference to an external file
References from one or more test data container
Runtime
Entered manually in start options
Subset of existing internal variants
Reference to different external file
The variant selection that you define at designtime can be re-defined at runtime
© SAP AG 2004, SAP TechEd / ABAP202 / 52
Demo
Demo
© SAP AG 2004, SAP TechEd / ABAP202 / 53
Uses for Test Configurations
Assign a test configurationto a project step in the Solution Manager or to a Test Catalog in the Test Organizer
Generate a Test Plan to assign individual tests to particular users
Motivation
Activatable Assertions & Breakpoints
ABAP Unit
GUI Scripting
eCATT
Summary
© SAP AG 2004, SAP TechEd / ABAP202 / 55
Summary
The SAP Development Environment supports testing in all phases of the development and deployment process
Use assertions and breakpoints for targeted error-detection
ABAP Unit provides a standardized ABAP-based test framework for developers to write unit tests
GUI Scripting allows you to record and replay sequences of actions in the SAP GUI
Functional testing of end-to-end business processes is possible using eCATT
© SAP AG 2004, SAP TechEd / ABAP202 / 56
Further Information
Public Web:www.sap.com
SAP Developer Network: www.sdn.sap.com
Search for ABAP Knowledge Center
SAP Customer Services Network: www.sap.com/services/
Related Workshops/Lectures at SAP TechEd 2004ABAP152, Automating Functional Tests with eCATT, Hands-onABAP201, Best of ABAP - The Ultimate ABAP 6.40 Feature Show, LectureABAP253, ABAP Troubleshooting, Hands-onABAP254, New Dynamic Test Tools for ABAP Developers, Hands-onJAVA351, Using eCATT to Test Web Dynpro Applications, Hands-on
Related SAP Education Training Opportunitieshttp://www.sap.com/education/
© SAP AG 2004, SAP TechEd / ABAP202 / 57
SAP Developer Network
Look for SAP TechEd ’04 presentations and videos on the SAP Developer Network.
Coming in December.
http://www.sdn.sap.com/
© SAP AG 2004, SAP TechEd / ABAP202 / 58
Q&A
Questions?
© SAP AG 2004, SAP TechEd / ABAP202 / 59
Please complete your session evaluation.
Be courteous — deposit your trash, and do not take the handouts for the following session.
Feedback
Thank You !
© SAP AG 2004, SAP TechEd / ABAP202 / 60
No part of this publication may be reproduced or transmitted in any form or for any purpose without the express permission of SAP AG. The information contained herein may be changed without prior notice.
Some software products marketed by SAP AG and its distributors contain proprietary software components of other software vendors.
Microsoft, Windows, Outlook, and PowerPoint are registered trademarks of Microsoft Corporation.
IBM, DB2, DB2 Universal Database, OS/2, Parallel Sysplex, MVS/ESA, AIX, S/390, AS/400, OS/390, OS/400, iSeries, pSeries, xSeries, zSeries, z/OS, AFP, Intelligent Miner, WebSphere, Netfinity, Tivoli, and Informix are trademarks or registered trademarks of IBM Corporation in the United States and/or other countries.
Oracle is a registered trademark of Oracle Corporation.
UNIX, X/Open, OSF/1, and Motif are registered trademarks of the Open Group.
Citrix, ICA, Program Neighborhood, MetaFrame, WinFrame, VideoFrame, and MultiWin are trademarks or registered trademarks of Citrix Systems, Inc.
HTML, XML, XHTML and W3C are trademarks or registered trademarks of W3C®, World Wide Web Consortium, Massachusetts Institute of Technology.
Java is a registered trademark of Sun Microsystems, Inc.
JavaScript is a registered trademark of Sun Microsystems, Inc., used under license for technology invented and implemented by Netscape.
MaxDB is a trademark of MySQL AB, Sweden.
SAP, R/3, mySAP, mySAP.com, xApps, xApp, SAP NetWeaver and other SAP products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of SAP AG in Germany and in several other countries all over the world. All other product and service names mentioned are the trademarks of their respective companies. Data contained in this document serves informational purposes only. National product specifications may vary.
These materials are subject to change without notice. These materials are provided by SAP AG and its affiliated companies ("SAP Group") for informational purposes only, without representation or warranty of any kind, and SAP Group shall not be liable for errors or omissions with respect to the materials. The only warranties for SAP Group products and services are those that are set forth in the express warranty statements accompanying such products and services, if any. Nothing herein should be construed as constituting an additional warranty.
Copyright 2004 SAP AG. All Rights Reserved