Testing In Java


Published on

1 Like
  • Be the first to comment

No Downloads
Total Views
On Slideshare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide
  • My background: Mostly C & Perl from 1990 – 1997 Mostly Java since then. Telemetry processing, mission ops, EIS @ JPL. BPM, workflow, assorted biz apps.
  • Goal falls within the larger context of pursuing excellence in software development.
  • In traditional software development, testing is usually at the end of the schedule. If development runs late, the testing often suffers.
  • An old man calls the waiter over to his table. "What would you like, sir?" asks the waiter. "Taste the soup," he says. "Is the soup too cold?" asks the waiter. "Taste the soup," says the old man. "Is it too salty?" asks the waiter. "Taste the soup!" says the old man. "Is there a fly in it?" asks the waiter. "Taste the soup!" the old man insists. The waiter looks down: "There's no spoon!" "Aha!" exclaims the old man.
  • Miriam-Webster: “ a program for the systematic monitoring and evaluation of the various aspects of a project, service, or facility to ensure that standards of quality are being met”
  • Test plan: document Test case: implementation of specific test. Test suite: collection of test cases. Test report: results of running the tests. Test coverage: description of how much code (and which code) was exercised by tests.
  • Unit test: typically at the granularity of a class. Functional test: a feature or use case. Integration test: multiple modules. System test: all the modules. Acceptance test: defined by user/customer.
  • Non-functional testing: the “-ilities”. Performance test: how fast. Load test: how many. Soak test: how long.
  • This is an alternative to “big bang integration”, otherwise known as “integration hell”.
  • HttpUnit is better suited to situations where you want to examine the DOM at a low level. If you're looking for convenience, and don't need to get deep into the details, look at Selenium instead.
  • Selenium IDE, a Firefox plugin, lets users or product managers create their own scenarios. Selenium is also useful during development, to quickly fast forward through actions to get the web application into a desired state.
  • The items in green aren't really a stack, just a collection of technology-specific libraries that can be useful for creating test cases.
  • Be sure to design Selenium tests so they can be repeatable. Either delete data when they are done, or always start from a fixed known state.
  • Testing In Java

    1. 1. David Noblednoble@exist.comSr. Solutions Architect, Exist GlobalTesting in JavaSan Gabriel Valley Java Users Grouphttp://www.sgvjug.org/June 25, 2007
    2. 2. GoalMotivate excellence in testingwith concepts, practices, and tools 2
    3. 3. Scope requirements quality Testing assurancecontinuous concepts,integration practices, tools static code analysis debugging profiling 3
    4. 4. Agenda Test-Driven Development Terminology Tools Application Discussion 4
    5. 5. System ConceptSystemRequirements System Design Detailed DesignImplementation Te Te http://www.flickr.com/photos/h2oalchemist/34249682 g g st st 9/ 5 iin n
    6. 6. DemoA Taste of TDD
    7. 7. Test-Driven Development Add test Fail Make small change Pass Pass Commit changes 7See also:
    8. 8. Test-Driven Development Add test Fail Fix bug Pass Commit changes 8
    9. 9. Test-Driven DevelopmentRefactor Pass Commit changes Code Add test Fail Make small change Pass Pass Commit changes 9
    10. 10. Test-Driven Development Small steps Frequent check-ins 10
    11. 11. Test-Driven Development Deeper than “test first” Design for testability 11
    12. 12. Test-Driven Development Unit tests as example code Interface before implementation Function drives form 12
    13. 13. Test-Driven Development Loose coupling Services with clear responsibilities Mock objects 13
    14. 14. Ta s t e thes oup ! 14http://flickr.com/photos/basak/227480302
    15. 15. Intent RealityRequirements, ImplementationArchitecture, ,Design Deployment 15
    16. 16. Intent RealityRequirements, ImplementationArchitecture, ,Design Deployment G ap ! 16
    17. 17. Intent Accountability RealityRequirements, Testing, QA ImplementationArchitecture, ,Design Deployment 17
    18. 18. Intent Accountability RealityRequirements, Testing, QA ImplementationArchitecture, ,Design R he Deployment ea c C lit k! y 18
    19. 19. Terminology QA – quality assurance Do the right things Do things right Ensure quality standards 19
    20. 20. Terminology Test – success criteria Is it right? Is it done? 20
    21. 21. Terminology Test plan Test case Test suite Test report Test coverage 21
    22. 22. Terminology Unit test Functional test Integration test System test Acceptance test Regression test 22
    23. 23. Terminology Non-functional testing Performance test Load test Soak test 23
    24. 24. Terminology Continuous integration 24
    25. 25. ToolsMock Objects jMock, EasyMock Unit Tests JUnit, TestNG Build Ant, Maven ID Eclipse, NetBeans E 25
    26. 26. Tools Web Apps Selenium, HttpUnit JEE Servers Cactus Databases DBUnit 26
    27. 27. Tools Acceptance Selenium, FitNesse, StiqPerformance JMeter, Eclipse TPTP Coverage Cobertura, Emma 27
    28. 28. Tools Continuous Cruise Control, Integration Continuum, Hudson 28
    29. 29. ToolsContinuous Integration Cruise Control, Continuum, Hudson Acceptance Selenium, FitNesse, Stiq Performance JMeter, Eclipse TPTP Coverage Cobertura, Emma Web Apps Selenium, HttpUnit JEE Servers Cactus Databases DBUnit Mock Objects jMock, EasyMock Unit Tests JUnit, TestNG Build Ant, Maven IDE Eclipse, NetBeans 29
    30. 30. Demo Tools
    31. 31. Resources: SGV JUGWeb Site http://sgvlug.net/mailman/listinfo/java-sigMailing List (Hosted by SGV Linux Users Group) http://sgvlug.net/mailman/listinfo/java-sig java-sig@sgvlug.net 31
    32. 32. Resources: TDDArticles http://www.agiledata.org/essays/tdd.html http://en.wikipedia.org/wiki/Test_driven_development http://www.testdriven.com/modules/xoopsfaq/ http://www.artima.com/intv/testdriven.html http://www.google.com/search?hl=en&q=test+driven+development (really!) 32
    33. 33. Resources: IDE & Build ToolsEclipse IDE http://www.eclipse.org/NetBeans IDE http://www.netbeans.org/Ant http://ant.apache.org/Maven 2 http://maven.apache.org/ http://www.devzuz.com/web/guest/products/resources#BBWMMaven & Eclipse http://m2eclipse.codehaus.org/Maven & Netbean http://maven.apache.org/guides/mini/guide-ide-netbeans/guide-ide-netbeans.html 33
    34. 34. Resources: Unit TestingJUnit Framework http://junit.org/JUnit FAQ http://junit.sourceforge.net/doc/faq/faq.htmJUnit with Ant http://ant.apache.org/manual/OptionalTasks/junit.html http://ant.apache.org/manual/OptionalTasks/junitreport.htmlJUnit with Maven http://maven.apache.org/plugins/maven-surefire-plugin/TestNG Framework http://testng.org/doc/Jester – Mutation Testing http://jester.sourceforge.net/ http://www.ibm.com/developerworks/java/library/j-jester/ 34
    35. 35. Resources: Mock ObjectsMock Objects Blog http://mockobjects.com/EasyMock Library http://easymock.org/jMock Library http://jmock.org/ 35
    36. 36. Resources: Unit & FunctionalXmlUnit Library http://xmlunit.sourceforge.net/DBUnit Library http://dbunit.sourceforge.net/HttpUnit Library http://httpunit.sourceforge.net/Cactus for JEE Server Code http://jakarta.apache.org/cactus/Cargo for JEE Server Code http://cargo.codehaus.org/ 36
    37. 37. Resources: Test CoverageCobertura http://cobertura.sourceforge.net/ http://www.ibm.com/developerworks/java/library/j-cobertura/Cobertura with Ant http://cobertura.sourceforge.net/anttaskreference.htmlCobertura with Maven http://mojo.codehaus.org/cobertura-maven-plugin/usage.htmlEmma http://emma.sourceforge.net/ 37
    38. 38. Resources: Perf. & LoadJUnitPerf http://clarkware.com/software/JUnitPerf.htmlJMeter http://jakarta.apache.org/jmeter/Eclipse TPTP (Test & Performance Tools Platform) http://www.eclipse.org/tptp/Netbeans Profiler http://profiler.netbeans.org/ 38
    39. 39. Resources: Acceptance TestsSelenium for Web Apps http://www.openqa.org/selenium/ http://www.openqa.org/selenium-ide/download.actionAutomating Selenium (“Remote Control”) http://www.openqa.org/selenium-rc/ http://wiki.openqa.org/display/SRC/Selenium-RC+and+Continuous+IntegrationSelenium & Maven http://raibledesigns.com/rd/entry/selenium_plugin_for_mavenFitNesse http://fitnesse.org/Stiq http://storytestiq.sourceforge.net/ 39
    40. 40. Resources: Cont. IntegrationCruise Control http://cruisecontrol.sourceforge.net/Continuum http://maven.apache.org/continuum/Hudson https://hudson.dev.java.net/ 40
    41. 41. Resources: App used in DemoOpen Source Medical Record System http://www.openmrs.org/Prerequisites: SVN, MySQL 5, Tomcat 5 http://subclipse.tigris.org/update_1.2.x http://mysql.org/ http://tomcat.apache.org/SVN Repository http://svn.openmrs.org/openmrs/branches/alphaInstallation Edit build.properties and properties.xml to set tomcat.user/password, or add test/test to $CATALINA_HOME/conf/tomcat-users.xml file. Edit build.properties and/or properties.xml to set tomcat.home file. Comment out creation of "test" MySQL user in schema if it already exists. Default username/password is admin/test. 41
    42. 42. Thank youTo all who participated!