Automation   Test   余昭辉   2011.10
I’m a…   Developer(C#, Java, Scala…)   Blogger(http://yuyijq.cnblogs.com)   Microsoft MVP(C#)I like…   CLR, JVM   OO,...
Tools
jUnit   Test Fixture       BeforeClass, AfterClass, Before, After,        assumeThat, Group Tests   Extensions       D...
Mock   Mockito   jMock   easyMock   MockObjects
Spring test   MockHttpServletRequest   MockHttpServletResponse   MockHttpSession   MockServletConfig   MockServletCon...
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)).f...
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      ...
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
Upcoming SlideShare
Loading in...5
×

Automation test

2,151

Published on

Published in: Technology, Business
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
2,151
On Slideshare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
19
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide
  • 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

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

      Clipping is a handy way to collect important slides you want to go back to later.

    ×