automated testing in sakai testing applications and services in isolation and in context josh...

17
Automated Testing in Sakai Testing applications and services in isolation and in context Josh Holtzman, UC Berkeley David Haines, University of Michigan

Upload: tyler-kelly

Post on 18-Jan-2018

218 views

Category:

Documents


0 download

DESCRIPTION

Why Formal Testing? Ensures that you know what the code is supposed to do Ensures that code does what it should do Ensures that the code doesn’t regress when changes are introduced Developer testing is not to avoid QA

TRANSCRIPT

Page 1: Automated Testing in Sakai Testing applications and services in isolation and in context Josh Holtzman, UC Berkeley David Haines, University of Michigan

Automated Testing in Sakai

Testing applications and services in isolation and in context

Josh Holtzman, UC Berkeley

David Haines, University of Michigan

Page 2: Automated Testing in Sakai Testing applications and services in isolation and in context Josh Holtzman, UC Berkeley David Haines, University of Michigan

Goals• Discuss developer-centric testing in Sakai

– Purposes– Concepts– Tools

• Demonstrate a simple running example of application and service testing

Page 3: Automated Testing in Sakai Testing applications and services in isolation and in context Josh Holtzman, UC Berkeley David Haines, University of Michigan

Why Formal Testing?

• Ensures that you know what the code is supposed to do

• Ensures that code does what it should do

• Ensures that the code doesn’t regress when changes are introduced

• Developer testing is not to avoid QA

Page 4: Automated Testing in Sakai Testing applications and services in isolation and in context Josh Holtzman, UC Berkeley David Haines, University of Michigan

Types of Testing

• Object (Logic/Unit) Testing• Integration Testing• Functional Testing• System Testing• Load Testing (Capacity, Stress, Performance)

Page 5: Automated Testing in Sakai Testing applications and services in isolation and in context Josh Holtzman, UC Berkeley David Haines, University of Michigan

Load Testing (Ops)

• Does it perform realistically?– Capacity – Can it deal with X users /

transactions per hour?– Stress – What happens when it gets

overloaded?– Performance – What model describes the

behavior of the system?– Tools - Loadrunner, jmeter, grinder

Page 6: Automated Testing in Sakai Testing applications and services in isolation and in context Josh Holtzman, UC Berkeley David Haines, University of Michigan

System Testing (QA)

• Can the entire system perform the required task?– Integrates the full software stack, including

the web server– Tools include httpunit, jmeter, jwebunit,

people, others

Page 7: Automated Testing in Sakai Testing applications and services in isolation and in context Josh Holtzman, UC Berkeley David Haines, University of Michigan

Functional Testing (Dev, QA)

• Test specific behavior in deployed systemCan a user really add a new site?

• Slowest method of developer testing• Tools

– Selenium-IDE, httpunit, jwebunit

Page 8: Automated Testing in Sakai Testing applications and services in isolation and in context Josh Holtzman, UC Berkeley David Haines, University of Michigan

Integration Testing (Dev)• Tests an object with a real environment

– Uses a test harness to bootstrap the application’s environment

– Test the object using true collaborators – Slow. Must start up the entire environment– Not a replacement for logic testing!

• Tools– Sakai test harness

Page 9: Automated Testing in Sakai Testing applications and services in isolation and in context Josh Holtzman, UC Berkeley David Haines, University of Michigan

Logic/Object/Unit Testing (Dev)• Test object behavior• Fastest kind of developer testing• Create an object, setup its local environment,

call a method, and verify its result is what as expected– Tests a single unit of code at a time– Does not test an object in a runtime environment– Must simulate collaborators as needed– Tests can and should be written before the

implementation– Write a failing test first!

Page 10: Automated Testing in Sakai Testing applications and services in isolation and in context Josh Holtzman, UC Berkeley David Haines, University of Michigan

Logic Testing (continued)• Tools

– Behavior - Junit– Runtime Environment

• Mock objects can help with collaborators (jmock, easymock)

• Stubs can help with collaborators (but get messy quickly)

• Dynamic proxies– Ecology - Coverage tools help assess how

much code has not been tested (jcoverage, clover)

Page 11: Automated Testing in Sakai Testing applications and services in isolation and in context Josh Holtzman, UC Berkeley David Haines, University of Michigan

Logic Testing (continued)• JUnit Architecture

– Test method– Test Cases– Test Suites

Page 12: Automated Testing in Sakai Testing applications and services in isolation and in context Josh Holtzman, UC Berkeley David Haines, University of Michigan

Types of Developer Testing

• Logic– Does this logic work correctly?

• Integration– Does it talk nice?

• Functional– Demonstrate that works in a deployment.

Page 13: Automated Testing in Sakai Testing applications and services in isolation and in context Josh Holtzman, UC Berkeley David Haines, University of Michigan

Logic Testing Demo

• Test– Test a single assertion

• TestCase– Collection of related tests– Uses fixtures for setup and teardown

• TestSuite– Collection of TestCases– Uses fixture for one time setup and teardown

Page 14: Automated Testing in Sakai Testing applications and services in isolation and in context Josh Holtzman, UC Berkeley David Haines, University of Michigan

Integration Testing

• Add real service and test to make sure data gets through

Page 15: Automated Testing in Sakai Testing applications and services in isolation and in context Josh Holtzman, UC Berkeley David Haines, University of Michigan

Functional Testing

• Does it work in a deployed system?• Get it up and deployed and running.• Click through and make sure it works.

Page 16: Automated Testing in Sakai Testing applications and services in isolation and in context Josh Holtzman, UC Berkeley David Haines, University of Michigan

Summary

• Anything not tested before production gets tested in production

• Fail first• Test what you are writing, not the whole

system• Changing code to be able to test is

often necessary• Refactoring is good

Page 17: Automated Testing in Sakai Testing applications and services in isolation and in context Josh Holtzman, UC Berkeley David Haines, University of Michigan

Resources

• JUnit– http://junit.org/– http://junit.sourceforge.net/doc/cookbook/cookbook.htm

• Mock objects– http://www.mockobjects.com– http://www-128.ibm.com/developerworks/library/j-mocktest.html

• Test harness– https://source.sakaiproject.org/svn/test-harness/trunk/xdocs/README-INTEGRATION-TESTING.txt

• Sample code– https://source.sakaiproject.org/playground/trunk/unittesttalk/hello-world/