intTypePromotion=1
zunia.vn Tuyển sinh 2024 dành cho Gen-Z zunia.vn zunia.vn
ADSENSE

Object-Oriented Testing

Chia sẻ: Nguyễn Phong | Ngày: | Loại File: PDF | Số trang:47

86
lượt xem
13
download
 
  Download Vui lòng tải xuống để xem tài liệu đầy đủ

Unit testing, but we expand the definition of unit Component testing to make sure individual subsystems work correctly Integration testing to make sure subsystems work correctly together System testing to verify that requirements are met Regression testing to make sure previous

Chủ đề:
Lưu

Nội dung Text: Object-Oriented Testing

  1. Object-Oriented Testing
  2. Contents  Why OO Testing?  Impact of OO on Testing  OO Testing Phases  Testing OO Systems  Specific OO Testing Techniques 2
  3. Why OO Testing? 3
  4. Why OO Testing?  Object-oriented development provides an abstract way of thinking a problem  Absent in traditional structured-oriented development  Techniques and tools for testing a traditional structured-oriented software are not sufficient to completely test object-oriented systems  OO poses some new challenges on testing systems  Conventional techniques can be used but they probably will not be enough 4
  5. OO Testing  OO Testing is Still “Testing”  We still do  Unit testing, but we expand the definition of unit  Component testing to make sure individual subsystems work correctly  Integration testing to make sure subsystems work correctly together  System testing to verify that requirements are met  Regression testing to make sure previous functionality still works after new functionality is added  But… 5
  6. OO Testing  Testing strategy changes  The concept of the unit broadens due to encapsulation  Integration focuses on classes and their execution across a thread or in the context of a use case  e.g. Do your classes work together to allow a user to complete a task from your scenarios?  Validation uses conventional black box methods  Test case design draws on conventional methods, but also encompasses special features 6
  7. OO Testing  Although  Object-oriented analysis and design can lead to a better system architecture, and  Object-oriented programming enforces a disciplined coding style  Object-Orientation does not  Shield against programmers’ mistakes or a lack of understanding of the specification  Ensure the production of correct programs by itself  Object-oriented systems still need Testing 7
  8. Impact of OO on Testing 8
  9. Impact of OO on Testing  Common features of OO development are complex and, therefore, prone to errors  Encapsulation  Information hiding  Inheritance  Consistency in abstraction hierarchy  Multiple inheritance  Polymorphism  Dynamic binding  Exception Handling 9
  10. Encapsulation  A control access mechanism that determines the visibility of methods and attributes in a class  Enforces information hiding  The interface and implementation of a class may be syntatically separated  Avoids undesirable dependencies between client and a server class  Only the class interface is visible to the client  Design decisions and implementation details are hidden  Encourages program modularity  Restricts the implication of changes 10
  11. Impact of Encapsulation on Testing  Testing requires  A complete report on the states of an object  The possibility to change states easily  Why does encapsulation make OO testing harder?  Lack of visibility of states  Besides the behavior encapsulated by an object, it also encapsulates states  Difficulty in initializing data items  Difficulty in calling methods  Encapsulation does not directly contribute to the introduction of faults, it may be an obstacle in testing by reducing controllability and observability 11
  12. Inheritance  Relationship between classes that allows the definition of a new (derived) class based on the definition of an existing (base) class  The derived class can then be refined by modifying or removing the inherited operations, or by adding new properties  Single inheritance  Properties are inherited from a single class  Strict: the derived class can only be refined by adding new properties  Subtyping: besides the properties of strict refinement, it allows the redefinition (overriding) of the inherited properties  Multiple inheritance  Properties are inherited from multiple (many) classes 12
  13. Inheritance  Allows reuse of both specification and implementation  Shares features present in classes previously defined  The preexisting classes do not have to be modified or made aware of the new class 13
  14. Inheritance  Inheritance can contribute to errors in several ways  Weakens encapsulation  Introduces hazards similar to those associated with global data in conventional languages  Used inappropriately as  A powerful macro substitution for convenience  A model of hierarchy  Can lead to homograph operations  Two or more classes with similar name and profile  When using multiple inheritance  Leads to side-effects, inconsistencies or incorrect behavior  Deep and wide inheritance hierarchies can defy comprehension  Leads to errors and reduction of testability 14
  15. Impact of Inheritance on Testing  Opens the issue of “retesting”  When do we need to retest the superclass?  When can we assume that the superclass has already been tested?  Should operations inherited from ancestor classes be retested in the context of the descendant class? 15
  16. Impact of Inheritance on Testing  Inheritance can lead to a false conclusion that...  Aspects already tested in the superclasses do not need to be retested in the subclasses  But, in fact, Inheritance defines new context for methods  Behavior of inherited methods can be changed because of other methods that are called within the inherited class  So  A method which has been tested in a superclass needs a retesting when it is reused by a subclass  Even if a method is inherited from a superclass without any modification (strict inheritance), it has to be retested in the subclass context 16
  17. Polymorphism  Ability to refer more than one type of object using the same name or variable  Replace explicit compile-time binding and static type checking by implicit binding and run-time type checking  Facilitate compact, elegant and extensible code  Sometimes constrained by inheritance 17
  18. Polymorphism  Polymorphism contributes to errors in several ways  likelihood of misusing a dynamically bound method increases  The combination of polymorphism and method refinement make it difficult to understand the behavior of lower level classes  Object polymorphism with late binding can result in messages being sent to the wrong class  Dynamic binding can cause a client class to  Assume/require a method not provided by the server class  Misuse an available method 18
  19. Impact of Polymorphism on Testing  Brings undecidability to testing  Dynamic binding: unanticipated bindings  Each possible binding of a polymorphic component requires a separate test  It may be difficult to find/exercise all such bindings  Erroneous casting (type conversions)  Can lead to non-easily detectable errors 19
  20. OO Testing Phases 20
ADSENSE

CÓ THỂ BẠN MUỐN DOWNLOAD

 

Đồng bộ tài khoản
2=>2