Tips for generating unit tests for Java code

Hi,

I’ve been using Cody Pro for about a month. It’s great in all areas, with the exception of generating unit tests for my Java projects. For Python, no major issues.

The Java project I’m testing isn’t very large or complex. I know some other coding assistants (e.g. GH Copilot) struggle with this due to limited project context. However, I thought that since Cody indexes my project and can theoretically “see” all my code (including my Maven POM file dependencies and versions), I’d get better results.

For example, when I highlight a single Java method and ask Cody to generate a unit test, the generated Java test class always contains a lot of errors. Some I can understand - because of the complexity of the “mocking” APIs. But, some are like it gets imports wrong, even though it should be able to “see” the correct Java packages, since they’re right in my project.

My questions are:
How much testing of this particular use case has the team performed?
Do you have any tips or online resources that might help me?
Or, is this just an inherent limitation with Java projects?

Thanks!
Tim