The way to set automation testing

Preview:

Citation preview

The way to set automation testing in Septeni Technology

Presenter: Nguyễn Thị Hiền – SQA at Septeni Technology

Hanoi, 2014/04/28

Introduction of us

• Septeni Technology CO., LTD is the strategic company in Hanoi of Septeni group so that we develop web services of our own in high level and speed.

• PYXIS is the software solution for managing Facebook Ad Campaigns and achieving the highest performance from your ads that is developed based on Web application platform.

Topic introduction

• At present, we are operating automation test for our PYXIS that are developed on Web application platform.

• We are using Selenium Webdriver (used language: Java) integrating with testNG to write automation test cases.

• Besides, we also use CI environment – Jenkins that is set up and configured by our developers to run test cases automatically everyday.

Outline1. Summarizing about automation test at Septeni Technology.

2. Create test cases by Selenium Webdriver integrating with testNG.

3. Run test cases automatically by using CI environment (Jenkins).

4. Send email notification to inform test results.

1. Automation test in Septeni TechnologySQA computer

+ Create test scripts based on manual testcases+ Using Selenium Webdriver integrating with

testNG.+ create and compile java file by using Eclipse and JAVA 1.7

Septeni technology server

Get test scripts files to run test automatically

Jenkins

Test results(Jenkins reports) Email notification

2. Create test cases by Selenium Webdriverintegrating with testNG

Why Selenium Webdriver?

Selenium Webdriver Selenium RC

1. Interact with browser directly undirectly

2. Interact with page’s elements in a more realistic way not a realistic way

3. API simple complicated

4. Can support the headless HtmlUnit browser?

yes no

5. Can connect to DB to executetest?

yes yes

2. Create test cases by Selenium Webdriverintegrating with testNG

Why TestNG?

1. TestNG can generate reports based on our Selenium test results.

- WebDriver has no native mechanism for generating reports.

- TestNG can generate the report in a readable format like the one shown below.

2. Annotations are easier to understand

3. Test cases can be grouped more easily

4. Parallel testing is possible

2. Create test cases by Selenium Webdriverintegrating with testNG

1. Choose testcases from the manual testcases to implement automating with Webdriver:

2. By extracting from this test case, we can design our test scenario automatically by Webdriver.

2. Create test cases by Selenium Webdriverintegrating with testNG

Test scenario:

Get Cost report value at Dashboard screen – screen cost

Query from DB to get expected cost report value - DB cost

screen cost = DB cost test passed

screen cost != DB cost test failed

2. Create test cases by Selenium Webdriverintegrating with testNG

1. Create test case

@BeforeTest: create a function to open brower and go to PYXIS-Dashboard screen

@BeforeTestpublic static void openWeb(){goToDashBoard();

}

@Test: create a function to implement test case Get Cost report value at Dashboard screen – screen cost Get Cost report value from DB – DB cost Compare screen cost and DB cost

@Test

public static void CheckCost() throwsInstantiationException,IllegalAccessException, ClassNotFoundException, SQLException {

// query to get cost value from db

String query = "SELECT IFNULL(SUM(adrep.spent),0) AS cost "

+ "FROM ad_reports_" + profileId + " adrep "

+ "INNER JOIN ads ON adrep.ad_id = ads.ad_id "

+ "WHERE ads.type IN (1,2,4,12)" + " and report_date BETWEEN "

+ getDate() + ";";

ResultSet result = (ResultSet) getResultFromDB(query);

// Get cost value from db

String costDB = "", realCost = "";

costDB = getValueFromDb(result, "cost");

realCost = driver.findElement(By.id("real_costs")).getText();

realCost = realCost.replaceAll("[^0-9]", "");

//Check cost at DB comparing with real cost

Assert.assertEquals(costDB, realCost);

}// end of checkCost

2. Create test cases by Selenium Webdriverintegrating with testNG@AfterTest: create a function to close browser after testing.

@AfterTest

public static void closeBrowser(){

driver.quit();

}

2. Convert to testNG

<suite name="Suite" parallel="none">

<test name="Test">

<classes>

<class name="checkDB.checkDB"/>

</classes>

</test> <!-- Test -->

</suite> <!-- Suite -->

2. Create test cases by Selenium Webdriverintegrating with testNG

Result after running test:

3. Run test cases automatically by using CI environment (Jenkins)

Why Jenkins?

1. Make is simpler and more convenient to run test case at server everyday automatically.

2. Can view result console easier and more convenient.

3. Provide a better view for manager and reporter to control the status of testing.

4. Sending email notification to concerned people.

3. Run test cases automatically by using CI environment (Jenkins) Create new job at Jenkins to run test cases automatically

Jenkins model:

Jenkins

Job

Build

Post build

Email notification

Export testNGresult

Export html report

3. Run test cases automatically by using CI environment (Jenkins)Report result after running test by Jenkins:

1. Html report:

4. Send email notification to inform test results

• Define Recipient List

• Content type: HTML because if using html we can show our test results clearly.

Thanks for your listening!

Summary

1. Automation test at Septeni Technogy by using Webdriverintegrating with testNG

2. Running test cases everyday automatically by using CI environment – Jenkins.

3. Export test result.

4. Send email notification via email.