Unit testing is a practical approach for increasing the correctness
and quality of software; but writing unit test code is exhausting and
tedious job; and requires a great deal of time and effort. So even
with the use of frameworks for writing and
running unit test such as
JUnit this will need a great deal of time and effort. As a
consequence, there is a pressure in writing testing code. So we
present in this paper a new method to generate unit testing
automatically in order to speed up the testing process and reduce
the cost. We have implemented this method on the Java
programming language, where we write a new specification called
JFS describes the behavior of the function in terms of input and
output. This specification is written inside the code class and is
independent of the code, and it can be written before starting the
code phase and thus achieve the principle TDD Test-Driven
Development which is based on written test-first in order to
improve the development process. After writing specification we
will generate test classes for the execution of unit testing (we used
JUnit as framework to execute unit testing) based on the new
specification.