Unit Testing
Unit Testing
• Approach #2
– Write a little code (e.g., a method or small
class)
– Test it
– Write a little more code
– Test it
– Integrate the two verified pieces of code
– Test it
Unit testing
• Large programs consist of many smaller
pieces
– Classes, methods, packages, etc.
Annotation Description
@BeforeClass public void method() Will execute the method once, before
the start of all tests. This can be used
to perform time intensive activities,
for example to connect to a database.
@AfterClass public void method() Will execute the method once, after
all tests have finished. This can be
used to perform clean-up activities,
for example to disconnect from a
database.