testing in java - pudn.comread.pudn.com/downloads157/ebook/697982/testing in java.pdf ·...
TRANSCRIPT
![Page 1: Testing in Java - pudn.comread.pudn.com/downloads157/ebook/697982/Testing in Java.pdf · 2009-03-22 · 3 Scope Testing concepts, practices, tools requirements static code analysis](https://reader030.vdocuments.us/reader030/viewer/2022040918/5e93d661ecc62629a240e1cc/html5/thumbnails/1.jpg)
Testing in Java
San Gabriel Valley Java Users Group
http://www.sgvjug.org/
June 25, 2007
David [email protected]
Sr. Solutions Architect, Exist Global
![Page 2: Testing in Java - pudn.comread.pudn.com/downloads157/ebook/697982/Testing in Java.pdf · 2009-03-22 · 3 Scope Testing concepts, practices, tools requirements static code analysis](https://reader030.vdocuments.us/reader030/viewer/2022040918/5e93d661ecc62629a240e1cc/html5/thumbnails/2.jpg)
2
Goal
Motivate excellence in testingwith concepts, practices, and tools
![Page 3: Testing in Java - pudn.comread.pudn.com/downloads157/ebook/697982/Testing in Java.pdf · 2009-03-22 · 3 Scope Testing concepts, practices, tools requirements static code analysis](https://reader030.vdocuments.us/reader030/viewer/2022040918/5e93d661ecc62629a240e1cc/html5/thumbnails/3.jpg)
3
Scope
Testingconcepts,practices,
tools
requirements
static codeanalysis
debuggingprofiling
continuousintegration
qualityassurance
![Page 4: Testing in Java - pudn.comread.pudn.com/downloads157/ebook/697982/Testing in Java.pdf · 2009-03-22 · 3 Scope Testing concepts, practices, tools requirements static code analysis](https://reader030.vdocuments.us/reader030/viewer/2022040918/5e93d661ecc62629a240e1cc/html5/thumbnails/4.jpg)
4
Agenda
Test-Driven Development
Terminology
Tools
Application
Discussion
![Page 5: Testing in Java - pudn.comread.pudn.com/downloads157/ebook/697982/Testing in Java.pdf · 2009-03-22 · 3 Scope Testing concepts, practices, tools requirements static code analysis](https://reader030.vdocuments.us/reader030/viewer/2022040918/5e93d661ecc62629a240e1cc/html5/thumbnails/5.jpg)
5http://www.flickr.com/photos/h2oalchemist/342496829/
System ConceptSystem Concept
System System RequirementsRequirementsSystem DesignSystem Design
Detailed DesignDetailed Design
ImplementationImplementation
Test
in
Test
in
gg
![Page 6: Testing in Java - pudn.comread.pudn.com/downloads157/ebook/697982/Testing in Java.pdf · 2009-03-22 · 3 Scope Testing concepts, practices, tools requirements static code analysis](https://reader030.vdocuments.us/reader030/viewer/2022040918/5e93d661ecc62629a240e1cc/html5/thumbnails/6.jpg)
DemoA Taste of TDD
![Page 7: Testing in Java - pudn.comread.pudn.com/downloads157/ebook/697982/Testing in Java.pdf · 2009-03-22 · 3 Scope Testing concepts, practices, tools requirements static code analysis](https://reader030.vdocuments.us/reader030/viewer/2022040918/5e93d661ecc62629a240e1cc/html5/thumbnails/7.jpg)
7
Test-Driven Development
Add test
See also: http://www.agiledata.org/essays/tdd.html
Make small change
Commit changes
Fail
PassPass
![Page 8: Testing in Java - pudn.comread.pudn.com/downloads157/ebook/697982/Testing in Java.pdf · 2009-03-22 · 3 Scope Testing concepts, practices, tools requirements static code analysis](https://reader030.vdocuments.us/reader030/viewer/2022040918/5e93d661ecc62629a240e1cc/html5/thumbnails/8.jpg)
8
Test-Driven Development
Add test
Fix bug
Commit changes
Fail
Pass
![Page 9: Testing in Java - pudn.comread.pudn.com/downloads157/ebook/697982/Testing in Java.pdf · 2009-03-22 · 3 Scope Testing concepts, practices, tools requirements static code analysis](https://reader030.vdocuments.us/reader030/viewer/2022040918/5e93d661ecc62629a240e1cc/html5/thumbnails/9.jpg)
9
Test-Driven Development
Add test
Make small change
Fail
PassPass
RefactorCode
Commit changesPass
Commit changes
![Page 10: Testing in Java - pudn.comread.pudn.com/downloads157/ebook/697982/Testing in Java.pdf · 2009-03-22 · 3 Scope Testing concepts, practices, tools requirements static code analysis](https://reader030.vdocuments.us/reader030/viewer/2022040918/5e93d661ecc62629a240e1cc/html5/thumbnails/10.jpg)
10
Test-Driven Development
Small steps
Frequent check-ins
![Page 11: Testing in Java - pudn.comread.pudn.com/downloads157/ebook/697982/Testing in Java.pdf · 2009-03-22 · 3 Scope Testing concepts, practices, tools requirements static code analysis](https://reader030.vdocuments.us/reader030/viewer/2022040918/5e93d661ecc62629a240e1cc/html5/thumbnails/11.jpg)
11
Test-Driven Development
Deeper than “test first”
Design for testability
![Page 12: Testing in Java - pudn.comread.pudn.com/downloads157/ebook/697982/Testing in Java.pdf · 2009-03-22 · 3 Scope Testing concepts, practices, tools requirements static code analysis](https://reader030.vdocuments.us/reader030/viewer/2022040918/5e93d661ecc62629a240e1cc/html5/thumbnails/12.jpg)
12
Test-Driven Development
Unit tests as example code
Interface before implementationFunction drives form
![Page 13: Testing in Java - pudn.comread.pudn.com/downloads157/ebook/697982/Testing in Java.pdf · 2009-03-22 · 3 Scope Testing concepts, practices, tools requirements static code analysis](https://reader030.vdocuments.us/reader030/viewer/2022040918/5e93d661ecc62629a240e1cc/html5/thumbnails/13.jpg)
13
Test-Driven Development
Loose coupling
Services with clear responsibilities
Mock objects
![Page 14: Testing in Java - pudn.comread.pudn.com/downloads157/ebook/697982/Testing in Java.pdf · 2009-03-22 · 3 Scope Testing concepts, practices, tools requirements static code analysis](https://reader030.vdocuments.us/reader030/viewer/2022040918/5e93d661ecc62629a240e1cc/html5/thumbnails/14.jpg)
14http://flickr.com/photos/basak/227480302/
Tastethe
soup!
![Page 15: Testing in Java - pudn.comread.pudn.com/downloads157/ebook/697982/Testing in Java.pdf · 2009-03-22 · 3 Scope Testing concepts, practices, tools requirements static code analysis](https://reader030.vdocuments.us/reader030/viewer/2022040918/5e93d661ecc62629a240e1cc/html5/thumbnails/15.jpg)
15
Requirements,Architecture,Design
Implementation,Deployment
RealityIntent
![Page 16: Testing in Java - pudn.comread.pudn.com/downloads157/ebook/697982/Testing in Java.pdf · 2009-03-22 · 3 Scope Testing concepts, practices, tools requirements static code analysis](https://reader030.vdocuments.us/reader030/viewer/2022040918/5e93d661ecc62629a240e1cc/html5/thumbnails/16.jpg)
16
Gap!Requirements,
Architecture,Design
Implementation,Deployment
RealityIntent
![Page 17: Testing in Java - pudn.comread.pudn.com/downloads157/ebook/697982/Testing in Java.pdf · 2009-03-22 · 3 Scope Testing concepts, practices, tools requirements static code analysis](https://reader030.vdocuments.us/reader030/viewer/2022040918/5e93d661ecc62629a240e1cc/html5/thumbnails/17.jpg)
17
RealityAccountability
Requirements,Architecture,Design
Testing, QA Implementation,Deployment
Intent
![Page 18: Testing in Java - pudn.comread.pudn.com/downloads157/ebook/697982/Testing in Java.pdf · 2009-03-22 · 3 Scope Testing concepts, practices, tools requirements static code analysis](https://reader030.vdocuments.us/reader030/viewer/2022040918/5e93d661ecc62629a240e1cc/html5/thumbnails/18.jpg)
18
Intent
Requirements,Architecture,Design
Testing, QA Implementation,Deployment
Realit
y
Chec
k!
RealityAccountability
![Page 19: Testing in Java - pudn.comread.pudn.com/downloads157/ebook/697982/Testing in Java.pdf · 2009-03-22 · 3 Scope Testing concepts, practices, tools requirements static code analysis](https://reader030.vdocuments.us/reader030/viewer/2022040918/5e93d661ecc62629a240e1cc/html5/thumbnails/19.jpg)
19
Terminology
QA – quality assuranceDo the right things
Do things right
Ensure quality standards
![Page 20: Testing in Java - pudn.comread.pudn.com/downloads157/ebook/697982/Testing in Java.pdf · 2009-03-22 · 3 Scope Testing concepts, practices, tools requirements static code analysis](https://reader030.vdocuments.us/reader030/viewer/2022040918/5e93d661ecc62629a240e1cc/html5/thumbnails/20.jpg)
20
Terminology
Test – success criteriaIs it right?
Is it done?
![Page 21: Testing in Java - pudn.comread.pudn.com/downloads157/ebook/697982/Testing in Java.pdf · 2009-03-22 · 3 Scope Testing concepts, practices, tools requirements static code analysis](https://reader030.vdocuments.us/reader030/viewer/2022040918/5e93d661ecc62629a240e1cc/html5/thumbnails/21.jpg)
21
Terminology
Test plan
Test case
Test suite
Test report
Test coverage
![Page 22: Testing in Java - pudn.comread.pudn.com/downloads157/ebook/697982/Testing in Java.pdf · 2009-03-22 · 3 Scope Testing concepts, practices, tools requirements static code analysis](https://reader030.vdocuments.us/reader030/viewer/2022040918/5e93d661ecc62629a240e1cc/html5/thumbnails/22.jpg)
22
Terminology
Unit test
Functional test
Integration test
System test
Acceptance test
Regression test
![Page 23: Testing in Java - pudn.comread.pudn.com/downloads157/ebook/697982/Testing in Java.pdf · 2009-03-22 · 3 Scope Testing concepts, practices, tools requirements static code analysis](https://reader030.vdocuments.us/reader030/viewer/2022040918/5e93d661ecc62629a240e1cc/html5/thumbnails/23.jpg)
23
Terminology
Non-functional testing
Performance test
Load test
Soak test
![Page 24: Testing in Java - pudn.comread.pudn.com/downloads157/ebook/697982/Testing in Java.pdf · 2009-03-22 · 3 Scope Testing concepts, practices, tools requirements static code analysis](https://reader030.vdocuments.us/reader030/viewer/2022040918/5e93d661ecc62629a240e1cc/html5/thumbnails/24.jpg)
24
Terminology
Continuous integration
![Page 25: Testing in Java - pudn.comread.pudn.com/downloads157/ebook/697982/Testing in Java.pdf · 2009-03-22 · 3 Scope Testing concepts, practices, tools requirements static code analysis](https://reader030.vdocuments.us/reader030/viewer/2022040918/5e93d661ecc62629a240e1cc/html5/thumbnails/25.jpg)
25
Tools
Eclipse, NetBeans
Ant, Maven
JUnit, TestNG
jMock, EasyMock
IDE
Build
Unit Tests
Mock Objects
![Page 26: Testing in Java - pudn.comread.pudn.com/downloads157/ebook/697982/Testing in Java.pdf · 2009-03-22 · 3 Scope Testing concepts, practices, tools requirements static code analysis](https://reader030.vdocuments.us/reader030/viewer/2022040918/5e93d661ecc62629a240e1cc/html5/thumbnails/26.jpg)
26
Tools
DBUnit
Cactus
Selenium, HttpUnit
Databases
JEE Servers
Web Apps
![Page 27: Testing in Java - pudn.comread.pudn.com/downloads157/ebook/697982/Testing in Java.pdf · 2009-03-22 · 3 Scope Testing concepts, practices, tools requirements static code analysis](https://reader030.vdocuments.us/reader030/viewer/2022040918/5e93d661ecc62629a240e1cc/html5/thumbnails/27.jpg)
27
Tools
Cobertura, Emma
JMeter, Eclipse TPTP
Selenium, FitNesse, Stiq
Coverage
Performance
Acceptance
![Page 28: Testing in Java - pudn.comread.pudn.com/downloads157/ebook/697982/Testing in Java.pdf · 2009-03-22 · 3 Scope Testing concepts, practices, tools requirements static code analysis](https://reader030.vdocuments.us/reader030/viewer/2022040918/5e93d661ecc62629a240e1cc/html5/thumbnails/28.jpg)
28
Tools
Cruise Control,Continuum,Hudson
ContinuousIntegration
![Page 29: Testing in Java - pudn.comread.pudn.com/downloads157/ebook/697982/Testing in Java.pdf · 2009-03-22 · 3 Scope Testing concepts, practices, tools requirements static code analysis](https://reader030.vdocuments.us/reader030/viewer/2022040918/5e93d661ecc62629a240e1cc/html5/thumbnails/29.jpg)
29
Tools
Eclipse, NetBeans
Ant, Maven
JUnit, TestNG
jMock, EasyMock
IDE
Build
Unit Tests
Mock Objects
DBUnit
Cactus
Selenium, HttpUnit
Databases
JEE Servers
Web Apps
Cobertura, Emma
JMeter, Eclipse TPTP
Selenium, FitNesse, Stiq
Coverage
Performance
Acceptance
Cruise Control, Continuum, HudsonContinuous Integration
Unit t
esting
![Page 30: Testing in Java - pudn.comread.pudn.com/downloads157/ebook/697982/Testing in Java.pdf · 2009-03-22 · 3 Scope Testing concepts, practices, tools requirements static code analysis](https://reader030.vdocuments.us/reader030/viewer/2022040918/5e93d661ecc62629a240e1cc/html5/thumbnails/30.jpg)
DemoTools
![Page 31: Testing in Java - pudn.comread.pudn.com/downloads157/ebook/697982/Testing in Java.pdf · 2009-03-22 · 3 Scope Testing concepts, practices, tools requirements static code analysis](https://reader030.vdocuments.us/reader030/viewer/2022040918/5e93d661ecc62629a240e1cc/html5/thumbnails/31.jpg)
31
Resources: SGV JUG
Web Sitehttp://sgvlug.net/mailman/listinfo/java-sig
Mailing List (Hosted by SGV Linux Users Group)http://sgvlug.net/mailman/listinfo/java-sig
![Page 32: Testing in Java - pudn.comread.pudn.com/downloads157/ebook/697982/Testing in Java.pdf · 2009-03-22 · 3 Scope Testing concepts, practices, tools requirements static code analysis](https://reader030.vdocuments.us/reader030/viewer/2022040918/5e93d661ecc62629a240e1cc/html5/thumbnails/32.jpg)
32
Resources: TDD
Articleshttp://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!)
![Page 33: Testing in Java - pudn.comread.pudn.com/downloads157/ebook/697982/Testing in Java.pdf · 2009-03-22 · 3 Scope Testing concepts, practices, tools requirements static code analysis](https://reader030.vdocuments.us/reader030/viewer/2022040918/5e93d661ecc62629a240e1cc/html5/thumbnails/33.jpg)
33
Resources: IDE & Build Tools
Eclipse IDEhttp://www.eclipse.org/
NetBeans IDEhttp://www.netbeans.org/
Anthttp://ant.apache.org/
Maven 2http://maven.apache.org/
http://www.devzuz.com/web/guest/products/resources#BBWM
Maven & Eclipsehttp://m2eclipse.codehaus.org/
Maven & Netbeanhttp://maven.apache.org/guides/mini/guide-ide-netbeans/guide-ide-netbeans.html
![Page 34: Testing in Java - pudn.comread.pudn.com/downloads157/ebook/697982/Testing in Java.pdf · 2009-03-22 · 3 Scope Testing concepts, practices, tools requirements static code analysis](https://reader030.vdocuments.us/reader030/viewer/2022040918/5e93d661ecc62629a240e1cc/html5/thumbnails/34.jpg)
34
Resources: Unit Testing
JUnit Frameworkhttp://junit.org/
JUnit FAQhttp://junit.sourceforge.net/doc/faq/faq.htm
JUnit with Anthttp://ant.apache.org/manual/OptionalTasks/junit.html
http://ant.apache.org/manual/OptionalTasks/junitreport.html
JUnit with Mavenhttp://maven.apache.org/plugins/maven-surefire-plugin/
TestNG Frameworkhttp://testng.org/doc/
Jester – Mutation Testing
http://jester.sourceforge.net/
http://www.ibm.com/developerworks/java/library/j-jester/
![Page 35: Testing in Java - pudn.comread.pudn.com/downloads157/ebook/697982/Testing in Java.pdf · 2009-03-22 · 3 Scope Testing concepts, practices, tools requirements static code analysis](https://reader030.vdocuments.us/reader030/viewer/2022040918/5e93d661ecc62629a240e1cc/html5/thumbnails/35.jpg)
35
Resources: Mock Objects
Mock Objects Bloghttp://mockobjects.com/
EasyMock Libraryhttp://easymock.org/
jMock Libraryhttp://jmock.org/
![Page 36: Testing in Java - pudn.comread.pudn.com/downloads157/ebook/697982/Testing in Java.pdf · 2009-03-22 · 3 Scope Testing concepts, practices, tools requirements static code analysis](https://reader030.vdocuments.us/reader030/viewer/2022040918/5e93d661ecc62629a240e1cc/html5/thumbnails/36.jpg)
36
Resources: Unit & Functional
XmlUnit Libraryhttp://xmlunit.sourceforge.net/
DBUnit Libraryhttp://dbunit.sourceforge.net/
HttpUnit Libraryhttp://httpunit.sourceforge.net/
Cactus for JEE Server Codehttp://jakarta.apache.org/cactus/
Cargo for JEE Server Codehttp://cargo.codehaus.org/
![Page 37: Testing in Java - pudn.comread.pudn.com/downloads157/ebook/697982/Testing in Java.pdf · 2009-03-22 · 3 Scope Testing concepts, practices, tools requirements static code analysis](https://reader030.vdocuments.us/reader030/viewer/2022040918/5e93d661ecc62629a240e1cc/html5/thumbnails/37.jpg)
37
Resources: Test Coverage
Coberturahttp://cobertura.sourceforge.net/
http://www.ibm.com/developerworks/java/library/j-cobertura/
Cobertura with Anthttp://cobertura.sourceforge.net/anttaskreference.html
Cobertura with Mavenhttp://mojo.codehaus.org/cobertura-maven-plugin/usage.html
Emmahttp://emma.sourceforge.net/
![Page 38: Testing in Java - pudn.comread.pudn.com/downloads157/ebook/697982/Testing in Java.pdf · 2009-03-22 · 3 Scope Testing concepts, practices, tools requirements static code analysis](https://reader030.vdocuments.us/reader030/viewer/2022040918/5e93d661ecc62629a240e1cc/html5/thumbnails/38.jpg)
38
Resources: Perf. & Load
JUnitPerfhttp://clarkware.com/software/JUnitPerf.html
JMeterhttp://jakarta.apache.org/jmeter/
Eclipse TPTP (Test & Performance Tools Platform)http://www.eclipse.org/tptp/
Netbeans Profilerhttp://profiler.netbeans.org/
![Page 39: Testing in Java - pudn.comread.pudn.com/downloads157/ebook/697982/Testing in Java.pdf · 2009-03-22 · 3 Scope Testing concepts, practices, tools requirements static code analysis](https://reader030.vdocuments.us/reader030/viewer/2022040918/5e93d661ecc62629a240e1cc/html5/thumbnails/39.jpg)
39
Resources: Acceptance Tests
Selenium for Web Appshttp://www.openqa.org/selenium/
http://www.openqa.org/selenium-ide/download.action
Automating Selenium (“Remote Control”)http://www.openqa.org/selenium-rc/
http://wiki.openqa.org/display/SRC/Selenium-RC+and+Continuous+Integration
Selenium & Mavenhttp://raibledesigns.com/rd/entry/selenium_plugin_for_maven
FitNessehttp://fitnesse.org/
Stiqhttp://storytestiq.sourceforge.net/
![Page 40: Testing in Java - pudn.comread.pudn.com/downloads157/ebook/697982/Testing in Java.pdf · 2009-03-22 · 3 Scope Testing concepts, practices, tools requirements static code analysis](https://reader030.vdocuments.us/reader030/viewer/2022040918/5e93d661ecc62629a240e1cc/html5/thumbnails/40.jpg)
40
Resources: Cont. Integration
Cruise Controlhttp://cruisecontrol.sourceforge.net/
Continuumhttp://maven.apache.org/continuum/
Hudsonhttps://hudson.dev.java.net/
![Page 41: Testing in Java - pudn.comread.pudn.com/downloads157/ebook/697982/Testing in Java.pdf · 2009-03-22 · 3 Scope Testing concepts, practices, tools requirements static code analysis](https://reader030.vdocuments.us/reader030/viewer/2022040918/5e93d661ecc62629a240e1cc/html5/thumbnails/41.jpg)
41
Resources: App used in Demo
Open Source Medical Record Systemhttp://www.openmrs.org/
Prerequisites: SVN, MySQL 5, Tomcat 5http://subclipse.tigris.org/update_1.2.x
http://mysql.org/
http://tomcat.apache.org/
SVN Repositoryhttp://svn.openmrs.org/openmrs/branches/alpha
InstallationEdit 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.
![Page 42: Testing in Java - pudn.comread.pudn.com/downloads157/ebook/697982/Testing in Java.pdf · 2009-03-22 · 3 Scope Testing concepts, practices, tools requirements static code analysis](https://reader030.vdocuments.us/reader030/viewer/2022040918/5e93d661ecc62629a240e1cc/html5/thumbnails/42.jpg)
Thank youTo all who participated!