2. About my company:
• Founded: Oct/2003
• Headquarter: Tokyo
• Services: Web & Smartphone
development
• Number of employees: 60
SeeSaa
Tokyo
Viet
Nam
Kyoto
9. Unit Test
Unit
Tes)ng
is
a
process
of
wri)ng
test
for
specific
part
of
code/system.
A
Unit
is
the
smallest
possible
part
of
applica)on/system
under
test.
Tes)ng
is
a
process
of
checking/evalua)ng
an
aJribute/characteris)cs/
capability
of
a
method/object/
program…
and
determining
that
actual
behavior
meets
with
expected
behavior.
10. Why should we do Unit Test ?
• How
about
Logger,
Debugger
?
Faster
debugging,
isn’t
it
?
• Not
sure,
even
slower!
Faster
development,
isn’t
it
?
• Let
see
an
example:
Faster
tes)ng
?
12. Why should we do Unit Test ?
• Instead
of
wri)ng
code
to
do
something,
you’re
star)ng
by
outlining
all
the
condi)ons
you’re
subjec)ng
the
code
to
and
what
outputs
you’d
expect
from
that
Designing
soUware
components
robustly
• Avoid
regression
errors
• You
test
the
code
once
and
the
con)nuously
aUerwards
• For
people
who
are
going
to
maintain
or
develop
your
code
Reduce
future
code
13. • Of
course,
are
developers
Who
create
Unit
Test
?
• Right
aUer
get
&
read
details
design/
requirement.
Where
in
project
development
?
14. • Depends
on
size
of
the
project
?
• Depends
on
kind
of
the
project
?
• Depends
on
level
of
the
developer
?
When
do,
when
don’t
?
15. • Process:
• Get & Read detail design document
• Choose a function to develop, then follow
to the diagram
• Take attention: whenever refactoring your
code, you should run unit test accordingly.
Along with adding new code, you need to
perform corresponding tests as well.
How to write a good Unit Test
16. Structure:
• Set up all conditions for testing
• Call the method (or trigger)
being tested
• Verify that the result is correct
• Teardown: clean up modified
records
How to write a good Unit Test
17. Some tips:
• Make each test independent to all the
others
• Test one thing only in one test case
• One function may have multiple unit
tests according to the usage and outputs
of the function
• Don’t forget to refactor the test code
• With little time and much to test you can’t
afford lengthy and ineffective checks.
Make test case simple, concentrate on
the core behavior of your product and
use as little code as you can.
• Creating maintainable & readable tests
How to write a good Unit Test