Software testing plays a major role in software development because it accounts for a large part of the development cost. Moreover, manual testing technique always makes a problem. Consequently, this paper proposes the automatic testing technique to solve partially the testing process. This technique can automatically generate and select test cases from UML statechart diagrams. Firstly, we transform this diagram into intermediate diagram, called Testing Flow Graph (TFG), explicitly identify flows of UML statechart diagrams and enhance for testing. Secondly, from TFG we generate test case using the testing criteria that is the coverage of the state and transition of diagrams. Finally, the evaluation is performed using mutation analysis to assess the fault revealing power of our test cases.