Automation test
Upcoming SlideShare
Loading in...5
×
 

Automation test

on

  • 2,257 views

 

Statistics

Views

Total Views
2,257
Views on SlideShare
1,112
Embed Views
1,145

Actions

Likes
0
Downloads
14
Comments
0

8 Embeds 1,145

http://www.cnblogs.com 1101
http://www.oschina.net 23
http://xianguo.com 10
http://reader.youdao.com 4
http://mailreader.163.com 3
http://www.zhuaxia.com 2
http://www.chenjiliang.com 1
http://cache.baiducontent.com 1
More...

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • If you modified some code, ensure you don’t break the test, if you break some tests, please fix it as quick as possible. You mustn’t leave the fail test to …

Automation test Automation test Presentation Transcript

  • Automation Test 余昭辉 2011.10
  • 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)
  • Tools View slide
  • jUnit Test Fixture  BeforeClass, AfterClass, Before, After, assumeThat, Group Tests Extensions  DbUnit, jsonAssert Hamcres  Matchers  More expression  Friendly assert result View slide
  • Mock Mockito jMock easyMock MockObjects
  • Spring test MockHttpServletRequest MockHttpServletResponse MockHttpSession MockServletConfig MockServletContext … ModelAndViewAssert
  • Selenium + WebDriver driver.get(“http://www.qunar.com”) driver.findElement(By.id(“login”)).click(); …
  • BDD(Cucumber) How to manage test cases? The relation between test cases and test code. QA and Dev
  • Principles
  • Test is a feedbackmechanism Run fast Run after each modified Run before check-in …
  • Test triangle Functional TestsIntegration TestsUnit Tests
  • State-based assert overbehavior-based assert assertThat(service.findById(1),is(expected)) verify(service,times(1)).findById(1);
  • assertThat over assertXxx Self description Different parameter type
  • Test behavior, not methods One behavior, one test Not one method many tests One test one assert(*)
  • Test method name isimportant Test method is document Give your intent:  testFindById is not a good name  should_find_agent_by_id is better  TestDox rule
  • Test data builder Agent agent = new AgentBuilder().build();
  • Repeat run Don’t modified database, transaction Prepare data itself, or write fixture
  • Test code is as important asproduct code We should extract duplicate code to method We should use good names …
  • Add test at: If you want to add println to get debug info If you find a bug, write a test first
  • Test as singal It’s very difficult to test Three steps:  Given  When  Then Test private methods
  • Demo
  • Remember Automated test can’t avoid bugs Even it can’t help you find bugs But it can avoid introduce bugs But…
  • Thank you