diversified at framework - initial version

21
Diversified Automation Testing Framework – Initial version May 27, 2015 Zhang Yu Tao

Upload: zhang-yu-tao

Post on 19-Jan-2017

123 views

Category:

Documents


3 download

TRANSCRIPT

Page 1: Diversified AT Framework - Initial Version

Diversified Automation Testing Framework – Initial version

May 27, 2015

Zhang Yu Tao

Page 2: Diversified AT Framework - Initial Version

document.docx

Table of Contents1. Automation Testing Framework - 3 -

1.1 Diagram of Automation Testing Framework - 3 -

1.2 Execution Environment - 3 -

1.3 Testing Tools - 3 -

1.4 Development Environment - 4 -

1.5 Code Structure - 4 -

1.6 Data Management - 5 -

1.7 Web Element Management - 6 -

1.8 API of Restful Web Service Management - 7 -

1.9 Command line of checking Windows VM Management - 9 -

1.10 Command line of checking Linux VM Management - 10 -

1.11 Write a Test Class - 12 -

1.12 Run scripts in Jenkins - 12 -

1.13 Run test class - 14 -

2. Approach for Test Automation - 15 -2.1 Description - 15 -

3. Reporting - 16 -

2

Page 3: Diversified AT Framework - Initial Version

document.docx

1. Automation Testing FrameworkThe framework is a standard framework of Maven Project, in which the tools Selenium and RestClient are integrated to support web browser and API (RESTFul webservice) automation testing, the tool JUnit is integrated to support automation test case written and a maven plugin Surefire is added to execute the automation test case in Maven’s lifecycle ‘test’. Outside the framework, tool Jenkins is involved to support continuous integration testing and remotely.

1.1 Diagram of Automation Testing Framework

1.2 Execution EnvironmentOS: Win XP or higher.Browser: Mozilla Firefox 2.6 or higher.

1.3 Testing Tools

Selenium (v2.39.0): a famous tool for automating web browsing testing and it supports mostly web control.

RestClient (v3.2.1): an open source tool to test RESTful webservices and it support most of types of RESTful webservice.

SSHJ (v0.9.0): an open source tool for executing SSH commands PowerShell Client: an tool developed by AT Team for executing PowerShell commands

3

Page 4: Diversified AT Framework - Initial Version

document.docx

1.4 Development Environment Java (v1.7.0): a language supports to integrate and develop new automation features. JUnit (v4.11): an environment is easy to write and execute test case. Maven (v3.1.1): a tool is easy to build java project and provides a good way to execute

JUnit test case. SVN (v1.7.x): a tool for storing code and version control.

1.5 Code Structure

src/main/java: main java classes for implementing automation of converged cloud automation.

engineering: put the Java classes for structuring and managing the testing project. repository.web: put the Java classes which represent UI element of website, in which

the methods of how to identify the UI element and what action the UI element provides are implemented.

repository.api: put the Java classes which represent APIs of each system, in which the methods of how to send request of an API, how to get the response and how to analysis

4

Page 5: Diversified AT Framework - Initial Version

document.docx

the response are implemented. Currently, the testing project just confronts the Restful webservice API, so there is only package repository.api.restful to put that classes right now.

repository.cmd: put the Java classes which represent Windows/Linux commands, in which the methods of how to execute the command, how to get the response and how to how to analysis the response are implemented. Currently, the testing project confronts the powershell and secureshell commonds, so there are packages repository.cmd.ps and repository.cmd.ssh to put that classes right now.

flow: put the Java classes which represent groups of step of each business flow of Converged Could.

utilities: put the common tool Java classes.

src/test/java

testcases: put the test classes which represent test cases of functionality testing, and they are in standard JUnit test case format.

src/test/resources: put external resource for classes of src/test/java

config.properties: stores global variables for the testing project. TestData.csv: a file used to store all test data.

1.6 Data Management

Use this TestDataManager.java to manage the test data. There are two steps to get data in a test class:

1. When you create a test case (java class), please add this scripts:

//give testname to the testEnvConfigurator.initializeFileEnvForTest();

If the parameter is null, the test class name will be considered as the Test Name which is referred in file TestData.csv.

If the parameter is not null, the given name will be referred in file TestData.csv.

5

Page 6: Diversified AT Framework - Initial Version

document.docx

2. After that, you can get the test data from the excel file by method ‘getTestData’. For example, String name = TestDataManager.getTestData(‘page_csp_name’, 1);

1.7 Web Element Management

The Package ‘repository.web’ is used to manage the web element. Every class in that package represents a web element in UI. (All the classes are implemented by using ‘org.openqa.selenium’ and the project ‘web’) For optimizing the efficiency of development and making the class easy to develop, these classes have been written in a parent-child relationship so that, to develop a new web element, developer often only needs to provide a suite of parameters to define the web element by using method ‘setCard’.

6

Page 7: Diversified AT Framework - Initial Version

document.docx

1.8 API of Restful Web Service ManagementIn this framework, we can use Restful webservice API to communicate with CSA, for example: get consumer ID, order ID etc. (All the classes are implemented by using ‘org.wiztools.restclient’ and project ‘restfulwebservice’)

For example: RestfGetConsumerID.java

7

Page 8: Diversified AT Framework - Initial Version

document.docx

For optimizing the efficiency of development and making the class easy to develop, these classes have been written in a parent-child relationship so that, to develop a new class, developer often only needs to provide the information of request by using method ‘setCard’.

Call this java code in test class:

8

Page 9: Diversified AT Framework - Initial Version

document.docx

1.9 Command line of checking Windows VM Management

In this framework, we can verify the detail information of windows VM by Powershell, for example: memory size, hardware etc. (All the classes are implemented by using project ‘powershell’)

For example: PSQueryCPU.java

For optimizing the efficiency of development and making the class easy to develop, these classes have been written in a parent-child relationship so that, to develop a new class, developer often only needs to provide the command lines by using method ‘setCard’.

Call this java code in test class:

9

Page 10: Diversified AT Framework - Initial Version

document.docx

1.10 Command line of checking Linux VM ManagementIn this framework, we can verify the detail information of Linux VM by SSHJ. (All the classes are implemented by using project ‘secureshell’)

For example: SSHQueryCPU.java

10

Page 11: Diversified AT Framework - Initial Version

document.docx

For optimizing the efficiency of development and making the class easy to develop, these classes have been written in a parent-child relationship so that, to develop a new class, developer often only needs to provide the command lines by using method ‘setCard’.

Call this java code in test class

1.11 Write a Test ClassThe progress is:

11

Page 12: Diversified AT Framework - Initial Version

document.docx

1. Create a new Class in package ‘testcases’ of source folder ‘src/test/java’.2. The class must extends class ‘TestCase’3. Call classes of packages ‘flow’ according to your necessary. 4. Below is an example for a standard test class:

Set the test name – Envconfigurator.initializeFileEnvForTest Import test data in test class – TestDataManager.getTestData call the ‘flow’ kind of class to complete a business flow log a test result – use class ‘reporter’ of package ‘engineering’

1.12 Run scripts in JenkinsJenkins is a website which can process maven project. For process a maven project, it asks to setup a job for the project firstly, then you can trigger the job manually or automatically according to your configuration of the job.

To run the test class of CCAT in Jenkins, you must ensure the computer has installed JDK1.7, Maven 3.1.1, and Mozilla Firefox (2.6 and higher).

To configure a job for CCAT:

12

Page 13: Diversified AT Framework - Initial Version

document.docx

To run the job of CCAT:

13

Page 14: Diversified AT Framework - Initial Version

document.docx

Run in Jenkins Slave:

Precondition: the Jenkins slave has been connected to a Jenkins master.

Firstly, we need to setup job in Jenkins mater, then we specific which Jenkins slave is used to run the job. Just need to fill the slave’s name in the job page is ok. The slave name you can find in the ‘manage Jenkins -> manage node’ in Jenkins.

Example:

http://c0005225.itcs.hp.com:8080/job/cc-at-suit1(C0005225)/

1.13 Run test class By default, we use maven command to run test class. Firstly, open window command line window, go to the root folder of CCAT then use following commands:

To run all test class: mvn test surefire-report: report-only

To specify test class to run: mvn –Dtest=test1,test2 test surefire-report: report-only

To clean all built classes after run: use command ‘clean’ before ‘test’ likes mvn clean test surefire-report: report-only

2. Approach for Test Automation2.1 DescriptionApproach for Test Automation is used for building a strategy for automation starting from the Requirement phase till the deployment phase. Approach for automation begins with finding out the conditions and business rules given by the client and grouping similar conditions, business rules together as Test Scenarios.

14

Page 15: Diversified AT Framework - Initial Version

document.docx

Steps involved in Approach for Test Automation are as follows:

Requirement gathering from Client Understanding and Analyzing the Requirement Grouping the requirement into Test cases Select manual case for Automation Preparing the Design for Automation Building Scripts depending on the Design Review of Scripts at Offshore Run and debug Scripts Run automation scripts / scenarios Delivery test report to the Client

Diagram of Approach for Test Automation:

15

Page 16: Diversified AT Framework - Initial Version

Identification of Test Cases for Automation

Identification of Common Functionality

Coding Standards, Naming Conventions & Templates

Implement classes of UI and related classes of method

Implement classes of API and related classes of method

Identification of flow and implementation of that

Test Class Development

Deliver the test class after Verification & Validation

document.docx

3. ReportingThe local report of CCAT generated from three parts:

Enhanced report: in the CCAT, we have code that works to log important stepsand generate report. The report will be stored in folder ‘./Report/Round_2014-02-21’ (the time is just a sample). Every test case will has its own folder in which there will be a file ‘report.txt’ and some screenshot file ‘.jpg’. The content of ‘report.txt’ comes from the code where you use methods of class ‘engineering.reporter’. The screenshot file comes from the code where you use method ‘screenshotOnWebDriver’ of class ‘method.Utility’, and if the test case met error or exception or fail, there will be an automatic screenshot.

16

Page 17: Diversified AT Framework - Initial Version

document.docx

Maven default report of command ‘test’: if use command ‘test’, after the maven command execution end, the default report will be generated in folder ‘./target/surefire-report’ for each test class. There are a txt and a XML file for the test result of one test class.(This report is merged in ‘report’ folder)

Maven default report of command ‘surefire-report: report-only’: if use command ‘surefire-report: report-only’, after the maven command execution end, a default report will be generated in folder ‘./target/site’. There is an html file generated by parsing all test results’ files of folder ‘surefire-report’ and then combining all information. (This report is merged in ‘report’ folder)

The report of Maven:

The report of Jenkins:

17

Page 18: Diversified AT Framework - Initial Version

document.docx

The Jenkins will generate own test result after job end. To retrieve it, you can go into the job and select ‘TestResult’.

18