Wso2 test automation framework internal training

1,299 views

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,299
On SlideShare
0
From Embeds
0
Number of Embeds
7
Actions
Shares
0
Downloads
22
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Wso2 test automation framework internal training

  1. 1. WSO2 Test AutomationFrameworkApproach and AdoptionByDharshana WarusavitharanaSenior Software Engineer, Test Automation
  2. 2. What will be Automated at WSO2● Platform scenarios.● Integration scenarios.● UI scenarios.● Real world use cases.● Performance and Security scenarios.● Patches provided.
  3. 3. Basic Understanding - Unit Test● Focused on testing behavior of aparticular class, module or method.● Smallest part of the application.● Fast (less than 0.1 second per test)● No external implementationdependencies(filesystem, database, web services, etc.). All dependencies arefaked for the test context.● Can easily be parallelized, since each test is atomic
  4. 4. Integration Test● Focused on verifying the integrationof one or more components together.● May have external dependencies.● A test that takes longer than a unitTest shouldIntegration Tests - with in WSO2● Executes on product pack created by build.● Not depending on other product environments.● Independent.● Lightweight.● Covers only scenarios related to features on individualproduct.
  5. 5. Overview of Automation FrameworkTest Automation Framework is to make automation● Eazy● Organized● Relevant● Optimized
  6. 6. Technology OutlineTest Framework Build SystemsCode CoverageTooling SupportExecution Environment
  7. 7. Flexibilities Provided By Automation Framework● Manage several products inside single test.● Manage users in several product domains.● Deployment of artifacts for different products under differentusers.● Automatic authentication.● Configured admin service clients as test oriented API.● Retrieving test environment configurations easily.● Running same test in both local and Stratos environments.● Reporting TestNg and surefire reports for all your tests.● Tooling support of Selenium and Jmeter.
  8. 8. Architecture Overview● Depends on TestNg Listeners.● Platform wide single framework● Context providing interfaces.● Admin Service based Automation API.● Selenium page object repository and element mapper.● Automation framework Utils.● Coverage and Reporting.
  9. 9. Why TestNG● Link JUnit but not JUnit● Annotation based Architecture● Test Grouping● Extensibility features○ Listeners○ Bean Shell○ Annotation Transformers● Easiness of managing Test cases.● Failed test execution (Straight and easy)
  10. 10. Automation Framework Overall Architectureuser.csv /tenant.csvautomation.propertiesinstrument.txtResultAutomation Framework CoreTestDashboardMavenTestManagersTest SuiteSurefireTestNg AutomationFramework APIAutomationFramework UtillsUserPopulatorCoverage(emmaServermanagerCustomReporterContextProvider
  11. 11. Framework CoreCorePlatformExecutionManagerPlatformSuiteManagerPlatformTestManagerPlatformAnnotationTransferManagerPlatformInvokedMethodManagerPlatformReportManagerEnvironmentContextFrameworkAnnotationsArtifact ManagementUser ManagementServer ManagementCoverageCustom Error Reporting
  12. 12. Execution Template - TestNgExecution Started@BeforeSuite@AfterSuiteExecution Closed@BeforeTest@AfterTest@BeforeClass@BeforeGroups@BeforeMethod@AfterMethod@AfterGroups@AfterClassReference:- http://www.ibm.com/developerworks/java/library/j-testng/
  13. 13. TestNg Listeners● Listeners are interfaces allows to modify TestNGsbehavior.● Listeners are binned to a testNg execution.● Listeners implement the interface org.testng.ITestListener○ IExecutionListener■ Triggers at start and end of any execution.■ ISuiteListener.○ ITestListner■ Triggers at suite start and end.■ Triggers at Test start, Finish, Failure, Skip and partial failure.● Reporters implement the interface org.testng.IReporter○ Notified when all the suites have been run by TestNG.○ The IReporter instance receives a summary of entire test run
  14. 14. Usage of Listeners● PlatformExecutionManager (IExecutionListener)○ onExecutionStart()■ Emma instrumentations■ Server start○ onExecutionFinish()■ Server Shutdown■ Emma report generation● PlatformSuiteManager (ISuiteListener)○ Set environment properties ex- Key Store Paths○ Populate Users.
  15. 15. Usage of Listeners contd..● PlatformReportManager (IReporter)○ Generate TestNg Report○ Generate surefire report○ Export data for Dashboard● PlatformInvokedMethodManager (InvokedMethodListener)○ Artifact deployment in platform scenarios.● PlatformAnnotationTransferManager (IAnnotationTransformer)○ Annotation-Platform-user type based test selection.
  16. 16. Context providing interfaces● Execution Based context - automation.properties● Platform Based Context - automation.properties● User Based Context - user.csv / tenant.csv● Coverage Based Context - instrumentation.txt
  17. 17. Automation Propertiesstratos.test=false#execution.environment = integration|platform|stratosexecution.environment=integration#execution.mode = user|tenant|allexecution.mode=userport.enable=truecarbon.web.context.enable=falseservice.deployment.delay=30000cluster.enable=trueproduct.list=ESBbuilder.enable=truecoverage.enable=true● To configure Test frameworkfor the environment andconfigure package details● Contains all information about The environment.
  18. 18. Server Management● Needs to configure the server and start the server with in thetest case.● Most of the cases it might be○ Single serve with single instance○ Single server with multiple instance○ Multiple product servers in a clustered environment.● In this module framework is managing○ Extract and configure the server.○ Add offsets and deploy custom modules needs for the test.
  19. 19. Test Execution Modes● Handled by a custom annotation introduced at test class and method level●●●● Annotations are based on the execution environment and the user type of the test● Tests are skipped at the "PlatformAnnotationTransferManager"● integration_all, integration_user, integration_tenant, platform_all, platform_user,platform_tenant, stratos, all@SetEnvironment(executionEnvironments = {ExecutionEnvironment.integration_all})public void createGroup() throws Exception{ }#execution.environment = integration|platform|stratosexecution.environment=integration#execution.mode = user|tenant|allexecution.mode=user
  20. 20. Automation Framework API● Test Friendly api wrapping service stubs.○ Depends on service stubs.○ Provides unified approach for perform verify and assertof each admin service.● Encapsulates the complexity of changing all available testsin a case of a stub change.● Maintain Page object classes for Selenium Automation.● Using UI maps to store locators required for test scripts.● Updates with the relevant release version.
  21. 21. Automation Framework Utils● Includes all utility classes that can play supportive role inside atest.○ Ex :-■ Axis2 Client.■ Wire message monitor.■ Custom server startup scenarios (Axis2, Tomcat,Qpid).■ Concurrency test scenarios.● Provides common methodology for all development teams tomaintain a set of supportive classes without changing the Core.● Reusability of utility methods in integration and platform tests.
  22. 22. Reporting● Includes TestNg reports ,SureFire report, And EmmaCoverage report● Directories containing separateresults for each suite ( Directoryname is as same as the suitename).● Surefire reports.● index.html (Dashboard forexecuted test).|-- reports| |-- BPSStructuredSuite| | |-- classes.html| | |-- FlowClient.html| | |-- FlowClient.properties| | |-- FlowClient.xml| | |-- ForEachClient.html| | |-- ForEachClient.properties| | |-- ForEachClient.xml| |-- index.html| |-- junitreports| | |-- TEST-org.wso2.automation.common.test.bps.mgts.BpelStructAct_FlowClient.xml| | |-- TEST-org.wso2.automation.common.test.bps.mgtst.BpelStructAct_forEachClient.xml
  23. 23. Platform Automated Test Suite● Distribution contain product integration and platform test jars.● ANT based test jar executor - using TestNg ant task● Ability to execute tests on different environments.● Provide options to run test suites, packages and individualclasses.● TestNg reports.● Generate mail with test results.
  24. 24. Project Structure of Automated Tests
  25. 25. Bit on Automation (Tips and Tricks)Referance - “Pragmatic Unit Testing in Java with JUnit” -Andrew Huntand David Thomas● Tip#1: One Assertion Per Test● Tip #2: Write a Test, Then Fix it● Tip #3: Keep Tests Independent● Tip #4: Use Good Design in Code & Tests● Tip #5: Test for Basic Correctness● Tip #6: You have made a mess So clean it.
  26. 26. Questions?

×