JUnitGenie is a framework for automating unit testing for software quality assurance. To overcome the limitations of existing methods that rely on fixed heuristics or limited contextual information, JUnitGenie combines code knowledge with the semantic power of LLM to generate path-sensitive unit tests. JUnitGenie extracts code knowledge from Java projects, generates structured prompts, and then generates high-coverage unit tests. In evaluations on 2,258 complex methods across 10 real-world Java projects, JUnitGenie improved branch and line coverage by an average of 29.60% and 31.00%, respectively, compared to existing methods, and identified real-world bugs that were subsequently fixed by developers.