Transcription
Leverage automationtesting with design patternsBodean Paul-Andrei
Summary Purpose of this research A general overview – project related Why design patterns The catalog of design patterns Classify patterns Analyze patterns Our top Extended research Q&A
Purpose of this research- Testing challenges Multiple platforms/technologies Complex applications Lack of human resources Time False failures Code duplication Spaghetti code
Purpose of this research- Possible solutions Hire more people to perform manual tests High cost with many resources Increase the automation coverage with alinear scripting framework Fast test cases implementation Need platform specific tools Low cost with resources Hard maintenance Build your own solid framework
Purpose of this research- The actual solution Build your own solid framework Modular Data driven Keyword driven BDD Hybrid Our approach Hybrid framework Designpatterns
A generaloverview –projectrelated
A generaloverview –projectrelated
Why design patternsTypical solutionsto commonlyexisting problemsSolve issuesusing provensolutionsCode reusabilitySolve problemsusing the OOPprinciplesReadabilityMinimum effort
The catalog of design patternsCreational Providedifferentobject creationrelatedsolutionsStructural Assembleobjects intolargerstructureskeeping thecode flexibleBehavioral Focused ontheresponsibilitiesbetweenobjects
Classify patternsCreationalSimplefactoryThe factorymethodBuilderSingletonTo becoveredAbstractfactoryPrototype
Classify patternsStructuralCompositeFacadeDecoratorPage objectAdaptorTo becoveredBridgeProxyFlyweight
Classify patternsBehavioralObserverChain ofresponsibilityStateCommandStrategyIteratorTo becoveredMediatorMementoTemplateMethodVisitor
AnalyzepatternsSimple factoryConcept Factory – a centralized place where thingsare getting created Simple factory - allow interfaces to createobjects without exposing the object creationlogic
AnalyzepatternsSimple factoryUsage
AnalyzepatternsThe factorymethodConcept Define an interface for creating an object butlet subclasses to decide which class toinstantiate Let a class to defer instantiation tosubclasses In terms of automated testing, it’s goodplace to start when building a modularframework Each component acts as a wrapper over theapplication pages
AnalyzepatternsThe factorymethodUsage
AnalyzepatternsBuilderConcept Separate the construction of an test from itsrepresentation, so the whole constructionprocess can create different representations We need a manager, a builder and a product Manager – construct a specific test using thebuilder Builder – construct and assemble parts ofthe test Product – the test to be created
AnalyzepatternsBuilderUsage
AnalyzepatternsBuilderUsage
AnalyzepatternsSingletonConcept Let you create a single class instance of agiven type Provide a global access point to it Automation usage: usually during theconnectivity with a driver
AnalyzepatternsSingletonUsage
AnalyzepatternsPage objectConcept The most popular pattern in SW automationtesting A page is an OOP class that servers as aninterface to a page under AUT The main idea is to group all the content of apage in an object, so it will encapsulate: Element IDS Interactions
AnalyzepatternsPage objectUsage
AnalyzepatternsCompositeConcept Compose objects into tree structures Automation related Test case design Design small test cases having one or alimited amount of steps Implement more complex testscomposed of the previously definedsimple tests Test plan definition - Treat a test plan as anobject composed from a set of test cases
AnalyzepatternsCompositeUsage
AnalyzepatternsFaçadeConcept Provide a single access point to a set of interfaces orclasses It’s an interface for all your available pages Automation usage: on the top of all the availablepages apply a single access point - your facade
AnalyzepatternsFaçadeUsage
AnalyzepatternsObserverConcept Define a relationship between object, if oneobject state is changed, the others will benotified Automation usage Automated performance testing
AnalyzepatternsObserverUsage
AnalyzepatternsStateConcept Allow an object to change it’s behavior, whenan internal state is changed Automation related: Define each test step as a state Facilitates the test cases debugging in caseof complex scenarios It helps us on the identification of any stepfrom a test case Prevent false failures by treating newpossible behaviors individually
AnalyzepatternsStateUsage
AnalyzepatternsStrategyConcept Define a family of algorithms, encapsulate each ofthem and make them interchangeable Strategy pattern give to the client the flexibility to usesame object with different algorithms Automation related Define a series of validators which could beaccessed by injecting them in a single interface Useful while using different validation algorithmsin many contexts
AnalyzepatternsStrategyUsage
Our top:1. Façade – entry point2. Page object – grouping3. Simple factory – organized access4. Singleton – one instance5. Observer - notification
Extended research- design-patterns- Personal blog: www.atechnovel.com
Analyze patterns Composite Concept Compose objects into tree structures Automation related Test case design Design small test cases having one or a limited amount of steps Implement more complex tests composed of the previously defined simple tests Test plan definition - Treat a test plan as an object composed from a set of test cases