Serializable
.People
in a file using serialization. This example contains also a class Test
.People
and Test
have been modified, in order to show that serialization runs even
when using references.In this example, we use JUnit in
order to test our classes.
First, if you want to use JUnit test with Eclipse, we recommand
to separate the sources of your program and the tests. For that,
create a new source folder in your project, for example named unittests.
Then choose a class for which you want to create a unit test and,
after a right-click, choose the item "New" and the item "JUnit
Test Case" in the submenu.
See the code of the example : People,
Directory,
DuplicatePeopleException
and the corresponding unit tests : PeopleTest
and DirectoryTest