Automated
Testing
John Paulett
jhcore.com
4.17.2009
testing sucks
buggy code sucks more
being an example on
thedailywtf.com sucks the most
types of testing
types of testing
unit
functional
types of testing
unit
security
usability
scaling
load
regression
functional
types of testing
smoke
accessibility
requirement unit
acceptance
touch
recovery
security
usability
scaling
load
regression
functional
types of testing
smoke
and more ... accessibility
requirement unit
acceptance
touch
recovery
security
usability
scaling
load
regression
functional
types of testing
smoke
and more ... accessibility
requirement unit
acceptance
touch
recovery
security
usability
scaling
load
regression
functional
types of testing
smoke
and more ... accessibility
requirement unit
acceptance
touch
recovery
unit testing
smallest testable part
method / function level
assertions
junit test case
import junit.framework.TestCase;
public class TestMath extends TestCase
{
public void testSquare() {
assertEquals(16, Math.square(4));
}
}
test drive development
public class Math {
public static int square(int x) {
return x;
}
}
failure
fix the bug
public class Math {
public static int square(int x) {
return x * x;
}
}
w00t!
forces better design
separate presentation from business logic
from data access!
“mock” out what your not testing
fake data access class when testing
business logic
every language has a unit
testing framework
even php
regression testing
know when things break
a test for every build
(and a build for every commit)
automate your build
hudson
hudson.dev.java.net
functional testing
selenium
seleniumhq.org
load testing
jmeter
jakarta.apache.org/jmeter/
requirements testing
fitnesse
fitnesse.org
test coverage
how much code is tested
eclemma.org
wuss excuses
wuss: i'm the only one on the
project
winner: i'll be ready for when
more people join
winner: i want my code to work
wuss: just for my research, not
production code
winner: i don't want to look like
a fool publishing buggy
results
wuss: i test it by using it
winner: i realize i never even
get close to testing all
of it after every change
wuss: it is already 1M LOC,
with no tests, it's too late
winner: i'll add a couple tests
when i fix a bug
key steps to start
1) unit test
on all new code
●
when you find a bug in existing code
●
work towards 100% branch coverage
●
2) automate your build, test every commit
est finis
slides at jhcore.com
write at least 1 unit test next time you code
get your test on!