Top Banner
Automation Test 余余余 2011.10
23

Automation test

Nov 01, 2014

Download

Technology

yuyijq

 
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Automation test

Automation Test余昭辉

2011.10

Page 2: Automation test

I’m a…

Developer(C#, Java, Scala…) Blogger(http://yuyijq.cnblogs.com) Microsoft MVP(C#)

I like… CLR, JVM OO, Design Pattern, Clean Code Agile(TDD, Code Review, Pair

Programming, etc)

Page 3: Automation test

Tools

Page 4: Automation test

jUnit

Test Fixture BeforeClass, AfterClass, Before,

After, assumeThat, Group Tests Extensions

DbUnit, jsonAssert Hamcres

Matchers More expression Friendly assert result

Page 5: Automation test

Mock

Mockito jMock easyMock MockObjects

Page 6: Automation test

Spring test

MockHttpServletRequest MockHttpServletResponse MockHttpSession MockServletConfig MockServletContext … ModelAndViewAssert

Page 7: Automation test

Selenium + WebDriver

driver.get(“http://www.qunar.com”) driver.findElement(By.id(“login”)).click(

); …

Page 8: Automation test

BDD(Cucumber)

How to manage test cases? The relation between test cases and

test code. QA and Dev

Page 9: Automation test

Principles

Page 10: Automation test

Test is a feedback mechanism

Run fast Run after each modified Run before check-in …

Page 11: Automation test

Test triangle

Functional

Tests

Integration Tests

Unit Tests

Page 12: Automation test

State-based assert over behavior-based assert

assertThat(service.findById(1),is(expected))

verify(service,times(1)).findById(1);

Page 13: Automation test

assertThat over assertXxx

Self description Different parameter type

Page 14: Automation test

Test behavior, not methods

One behavior, one test Not one method many tests One test one assert(*)

Page 15: Automation test

Test method name is important

Test method is document Give your intent:

testFindById is not a good name should_find_agent_by_id is better TestDox rule

Page 16: Automation test

Test data builder

Agent agent = new AgentBuilder().build();

Page 17: Automation test

Repeat run

Don’t modified database, transaction Prepare data itself, or write fixture

Page 18: Automation test

Test code is as important as product code

We should extract duplicate code to method

We should use good names …

Page 19: Automation test

Add test at:

If you want to add println to get debug info

If you find a bug, write a test first

Page 20: Automation test

Test as singal

It’s very difficult to test Three steps:

Given When Then

Test private methods

Page 21: Automation test

Demo

Page 22: Automation test

Remember

Automated test can’t avoid bugs Even it can’t help you find bugs But it can avoid introduce bugs But…

Page 23: Automation test

Thank you