Software testing is a process created to detect anomalies in the operation of a program or system in order to achieve the expected results. White box testing is a software testing method that tests the internal structure, design and program code. This research aims to produce an optimization method for white box testing in Java programs by utilizing branching and repetition structures using the basis path method, as well as analyzing the effectiveness of the proposed method in generating test cases. The Java program tested in this research includes input function calls, loops, branching, and exception handling. Test case design is carried out by applying the basis path method to achieve comprehensive coverage. The test results show that the base path method is able to produce effective test cases for testing control structures without redundancy. Test case design is assisted by flowgraph and matrix graph modeling. It is hoped that this research can contribute to the optimization of white box testing techniques.