This research addresses the pressing need to enhance software testing, specifically focusing on white-box testing and basis path generation. Software testing is a linchpin in the software development process, ensuring software operates flawlessly and aligns with its intended objectives. However, this phase often incurs substantial time and resource investments. The primary aim of this study is to introduce an efficient and automated approach for basis path generation, a crucial component of white-box testing. The model commences by transforming source code into a tailored control flow graph (CFG), streamlining the automated generation of test paths. Central to this model is an algorithm for generating test paths (AGTP), meticulously traversing CFG nodes from source to destination. The algorithm’s design aims to comprehensively cover all test paths within the CFG. To enhance testing process efficiency, the model employs k-means clustering to generate and cluster inputs. Path coverage is rigorously assessed for each cluster, and fuzzy logic is used to determine the optimal path. The overarching goals of this research are to reduce time and financial costs associated with software testing while maintaining precision and efficiency. The model’s effectiveness in generating test cases is confirmed through the examination of multiple examples, underscoring its valuable contribution to software testing. This study marks a significant advancement toward more effective and cost-efficient software testing methodologies.