testing in java - pudn.comread.pudn.com/downloads157/ebook/697982/testing in java.pdf ·...

Post on 07-Apr-2020

7 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Testing in Java

San Gabriel Valley Java Users Group

http://www.sgvjug.org/

June 25, 2007

David Noblednoble@exist.com

Sr. Solutions Architect, Exist Global

2

Goal

Motivate excellence in testingwith concepts, practices, and tools

3

Scope

Testingconcepts,practices,

tools

requirements

static codeanalysis

debuggingprofiling

continuousintegration

qualityassurance

4

Agenda

Test-Driven Development

Terminology

Tools

Application

Discussion

5http://www.flickr.com/photos/h2oalchemist/342496829/

System ConceptSystem Concept

System System RequirementsRequirementsSystem DesignSystem Design

Detailed DesignDetailed Design

ImplementationImplementation

Test

in

Test

in

gg

DemoA Taste of TDD

7

Test-Driven Development

Add test

See also: http://www.agiledata.org/essays/tdd.html

Make small change

Commit changes

Fail

PassPass

8

Test-Driven Development

Add test

Fix bug

Commit changes

Fail

Pass

9

Test-Driven Development

Add test

Make small change

Fail

PassPass

RefactorCode

Commit changesPass

Commit changes

10

Test-Driven Development

Small steps

Frequent check-ins

11

Test-Driven Development

Deeper than “test first”

Design for testability

12

Test-Driven Development

Unit tests as example code

Interface before implementationFunction drives form

13

Test-Driven Development

Loose coupling

Services with clear responsibilities

Mock objects

14http://flickr.com/photos/basak/227480302/

Tastethe

soup!

15

Requirements,Architecture,Design

Implementation,Deployment

RealityIntent

16

Gap!Requirements,

Architecture,Design

Implementation,Deployment

RealityIntent

17

RealityAccountability

Requirements,Architecture,Design

Testing, QA Implementation,Deployment

Intent

18

Intent

Requirements,Architecture,Design

Testing, QA Implementation,Deployment

Realit

y

Chec

k!

RealityAccountability

19

Terminology

QA – quality assuranceDo the right things

Do things right

Ensure quality standards

20

Terminology

Test – success criteriaIs it right?

Is it done?

21

Terminology

Test plan

Test case

Test suite

Test report

Test coverage

22

Terminology

Unit test

Functional test

Integration test

System test

Acceptance test

Regression test

23

Terminology

Non-functional testing

Performance test

Load test

Soak test

24

Terminology

Continuous integration

25

Tools

Eclipse, NetBeans

Ant, Maven

JUnit, TestNG

jMock, EasyMock

IDE

Build

Unit Tests

Mock Objects

26

Tools

DBUnit

Cactus

Selenium, HttpUnit

Databases

JEE Servers

Web Apps

27

Tools

Cobertura, Emma

JMeter, Eclipse TPTP

Selenium, FitNesse, Stiq

Coverage

Performance

Acceptance

28

Tools

Cruise Control,Continuum,Hudson

ContinuousIntegration

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

DemoTools

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

java-sig@sgvlug.net

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!)

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

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/

35

Resources: Mock Objects

Mock Objects Bloghttp://mockobjects.com/

EasyMock Libraryhttp://easymock.org/

jMock Libraryhttp://jmock.org/

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/

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/

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/

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/

40

Resources: Cont. Integration

Cruise Controlhttp://cruisecontrol.sourceforge.net/

Continuumhttp://maven.apache.org/continuum/

Hudsonhttps://hudson.dev.java.net/

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.

Thank youTo all who participated!

top related