Anda di halaman 1dari 3

12/11/12 7 Mistakes of Software Testing | Agile Zone

1/3 agile.dzone.com/articles/7-mistakes-software-testing-0
/ 2* ,1 25 - 2,1 Search
AGILE ZONE
6ROXWLRQV,4 $J LOH 7KURXJ K DQG7KURXJ K
Try Mingle 12.3 for FREE!
Hosted Trial, with VMware Image
and Production Ready Server
Whitepaper: Challenging ALM
Rapidly respond to change and
Know how to pick your tools!
Whitepaper: Problem w/ Roll-ups
Get insight into the problems that
roll-up forecasts can cause
0 LVWDNHVRI 6RIWZDUH7HVWLQJ
12.03.2012
|
4330 views
|
Like 2 Tweet Tweet 29 8
The Agile Zone is presented by ThoughtWorks Studios. Take advantage of their agile experts Jez
Humble and Martin Fowler. Learn more about their FREE Continuous Delivery toolchain.
Though most developers know the importance of testing, it seems that a lot of them still arent testing
enough. And if they write tests, they just test wrong.
81,7 7( 676
If some tests are written in applications, most of them will be unit tests. Its easy to test a utility class
by just calling all utility methods, passing some values and checking if the expected result is returned.
A first mistake arises here. Most people dont think out of the box, or not enough. You can test that 1 +
1 =2 , that 2 + 1 = 3 and that 3 + 1 = 4. But whats the benefit of doing almost the same test 3 times?
Its better to test the boundary cases. Are the arguments of the sum( ) method primitive types or
Objects? If they are Objects, what happens if you pass null values? If an exception is thrown, is that
the expected one? Does it clearly tell what the problem is?
0 2 &. 6
If for example the service layer is unit tested, all other components like the DAO layer should be
mocked. In many cases this is done manually. Thats a second mistake.
By mocking stuff manually your mocks are thightly coupled to the implementation. Its much better to
use mocking frameworks. They are made for it. Just trust that they will create the mocks the way you
want. Some mocking frameworks are capable of doing more than others, some are easier to use than
others. My favourite mocking framework is Mockito because of its power and simplicity. EasyMock is
by far the best known but imo a bit too complex to use. What was the sequence again? Expect, replay,
assert, or ?
So its not only a matter of choosing a mocking framework. Its also a matter of choosing the right one.
Agile Zone is brought to you in partnership with:
* OHQQ HMDHJ HU
%LR : HEVLWH @glenndejaeger
Share Share 3
Publish an Article Publish an Article Share a Tip Share a Tip
Follow Follow 18K f ollowers
DZone, Inc. on Follow
&2 11( &7 : ,7+ =2 1(
5( &2 0 0 ( 1 ( / ,1 . 6
HY2 SV HSOR\ P HQW $SSO\ LQJ $J LOHDQG
/ HDQ
: KDW$UH<RXU7RS 3URMHFW0 QJ P W
) HDWXUHV"
( %RRN 7KH3UREOHP ZLWK5ROO8SV
&KDOOHQJ LQJ $/ 0 &KRRVLQJ WKH%HVW7RROV
7U\ 0 LQJ OH3URMHFW0 DQDJ HP HQWIRU) UHH
7KH 3LDQRGRUR 7DNH
<RXU3URGXFWLYLW\ WR
3RZHU / HYHO
0 DNH7HFKQLFDO HEW
( [ SOLFLW
6SRWOLJ KW) HDWXUHV
+2 0 ( 5( ) &$5 = 0 ,&52 =2 1( 6 =2 1( 6 / ,%5$5< 61,33( 76 7872 5,$/ 6
12/11/12 7 Mistakes of Software Testing | Agile Zone
2/3 agile.dzone.com/articles/7-mistakes-software-testing-0
,17( * 5$7,2 1 7( 676
Integration tests are tests over different integrated parts of an application while unit tests only tests a
LUW (logical unit of work). The best known type of integration tests are tests of the DAO layer. In
these tests, multiple things are validated: the input parameters, the use of the ORM tool, the
correctness of the generated query (functional), if the DB can be accessed, the fact that the query is
working and the fact that the correct ResultSet is returned.
A third mistake that is made often is that developers provide test data in a dbUnit XML dataset. This
data is most of the time no representation of live data. The best way to handle this is to make
functional people provide and maintain this test data. Because you dont want to make them struggle
with a specific XML format, its a good practice to use the XlsDataSet format. Data can be provided in
an Excel sheet. The name of the tab is the table, in the first row, each column contains the name of
the column and in all other rows, effective data is added. Insertion into the DB will be done tab per tab,
from left to right. Deletion is done the other way around.
FUNCTIONAL TESTS
Functional test are forgotten too often because the perception is that they are difficult and costly to
maintain. Its true that youll have to tweak them to make them maintainable but executing all the same
tests manually over and over again will cost much more. Also when functionality is tested and
automated by means of continuous integration, theres no need for stress for screens/functionality that
will be broken in the next release.
Selenium is a great framework that is able to record functionality in the browser. Afourth mistake is
made here. Most people will just record and replay the tests the way they are. Selenium keeps tracks
of HTML components by their HTML id. If you dont specify ids in your HTML code, they can easily
change if a page is updated. This will break the tests immediately even when functionality still works.
A fifth mistake is made by just pasting the recorded test in a JUnit test. Common functionality like
login and logout, the time to wait for a response, should be added to a higher level. For example, a
login can be done before each test, afterwards a logout is done. This way, if something changes in
login or logout functionality, tests wont break.
A sixth mistake is the absence of testing logical flows. Its perfectly possible that an insert, a search,
an update, and a delete work on their own but that the complete flow from the creation, search, update
until delete of the same entry wont work. TestSuites are a great way to group multiple tests and run
them in sequence all together.
BDD
Mistake number seven: most of the tests are technical tests instead of functional tests. Its much
more important to test logical behaviour than to test if the things work technically. That can be done by
means of Behavior Driven Design.
Given some things, when an event occurs, then what should be the outcome? Mockito has some great
stuff to easily write tests in a BDD way.
Published at DZone with permission of Glenn Dejaeger, author and DZone MVB. (source)
(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)
7DJ V 7LSVDQG7ULFNV 7HVWLQJ
ThoughtWorks Studios knows Agile. In fact, one of their key leaders, Martin Fowler, helped draft the
Agile Manifesto over 10 years ago. See how ThoughtWorks Studios is creating tools and resources
that help organizations find the right configuration of agile for their teams. Agile Zone is your essential
hub for Scrum, XP, Kanban, Lean Startup and more.
$52 81 7+( =2 1( 1( 7: 2 5.
$OO5RDGV/ HDGWR 5RP H
) RU HY2 SV D\ V
%RRN3UHYLHZ HY2 SV
I RU HYHORSHUV
32 38 / $5 $7 =2 1 (
See more popular at DZone
Subscribe to the RSS feed
SCM Patterns Cheat Sheet from DZone
Refcardz
How to Control & Correct "On the Fly"
Javascript Violations in Eclipse
A Parable of Why Agile Methods Can
Save Money
Top 10 Lessons Learned From 10 Years
in Agile
Top 5 SOA Gotchas and How to Avoid
Them
Agile Program Management - How
Will You Deliver?
Variance Analysis, Irrational Markets,
and More Data Links of the Week
Online Visitors: 498
12/11/12 7 Mistakes of Software Testing | Agile Zone
3/3 agile.dzone.com/articles/7-mistakes-software-testing-0
I'm Going to Make a Lot of People Mad: Criticizing the Uncriticizable
Microsoft at the End of the World: 2012 in Review
When Using Direct Memory in Java Can be Faster
How I Got My Kids Into Programming
7 Mistakes of Software Testing
The 4 Most Important Skills for a Software Developer
IntelliJ IDEA 12 is Available for Download
Algorithm of the Week: Longest Increasing Subsequence
NoSQL Week in Review #7
Should You Trust the Default Settings in JVM?
Groovy's RESTClient with Spock Extensions
Weekly Poll: Cloud Experience
Ten Things You Can Do With Spring Security
Using Groovy and Camel for Scripting
Why Great Teams Build Great Products
<2 8 0 ,* +7 $/ 62 / ,. (
Search
Refcardz Book Reviews
Tech Library IT Questions
Snippets My Profile
About DZone Advertise
Tools & Buttons Send Feedback
=RQH
HTML5 Windows Phone
Cloud Mobile
.NET Java
PHP Eclipse
Performance Big Data
Agile DevOps
7RSLFV
Google +
Facebook
LinkedIn
Twitter
) ROORZ 8V
-Pithy Advice for Programmers
"Starting from scratch" is
seductive but disease ridden
JAVALOBBY
The DZone
Community's 2012
Developer Profile
ARCHITECTS
Hadoop on Azure: An
Introduction
JAVALOBBY
Is Programming the
Art of Making the Right
Decisio...
JAVALOBBY
Modern concurrency
and Java EE
ARCHITECTS
Lightweight RPC with
ZeroMQ (MQ) and
Protocol Bu...
ARCHITECTS
How to Be Big-Data-
Native
32 38/ $5 2 1 $* ,/ ( =2 1(
One Night With Clojure Makes a
Scala Guy Humble
Things to do to improve code quality
Top DZone Article of 2011 - 10
Mistakes That Software Team
Leads Make
Promiscuous Integration vs
Continuous Integration
Introducing Kanban, Flow, and
Cadence
Defining Kanban
Beware Of The Second Worst
Programmer
Death to Best Practices
/ $7( 67 $57,&/ ( 6
Algorithm of the Week: Topological
Sort Revisited
Baby Steps, Reverse Refactoring
and DNA
Improving AppFuse's PageSpeed
with Apache
Migrating from a Relational to a
NoSQL Cloud Database
Hazelcast Distributed Execution
with Spring
Manfiesto for Software
Craftsmanship
Common Uses of CUBRID Node.js
API with Examples
31 Days of Windows 8 for HTML5 |
Day #30: Store
63 2 7 / , * + 7
5 ( 62 8 5 &( 6
3DWWHUQVRI
0 RGXODU
$UFKLWHFWXUH
6FDOD 7KH
6FDODEOH- 90
/ DQJ XDJ H
Scala is a general-
purpose
programming
language that has
both object oriented
and functional
programming
language features.
The name Scala
comes...
- DYD3URI LOLQJ
ZLWK 9LVXDO90
; 5D\ 9LVLRQ
I RU UDP DWLF
3HUI RUP DQFH
* DLQV
VisualVM is a visual
tool integrating several
command-line JDK tools
and lightweight prof iling
capabilities. Designed
f or both production...
$GYHUWLVLQJ 7HUP VRI 6HUYLFH 3ULYDF\ i =RQH ,QF

Anda mungkin juga menyukai