The goals of the software testing are to assess and improve the quality of the software. An important problem in software testing is to determine whether a program has been tested enough with a testing criterion. To raise a technology to reconstruct the program structure and generating test data automatically will help software developers to improve software quality efficiently. Program recognition and transformation is a technology that can help maintainers to recover the programs’ structure and consequently make software testing properly. In this paper, a methodology to follow the logic of a program and transform to the original program graph is proposed. An approach to derive testing paths automatically for a program to test every blocks of the program is provided. A real example is presented to illustrate and prove that the methodology is practicable. The proposed methodology allows developers to recover the programs’ design and makes software maintenance properly.