Unit testing in Java

While (luckily) at our first regional I was debugging some of our vision code that wasn’t working. It turned out to be some code that was completely independent of FRC specific classes and someone from another team mentioned that this was basically the perfect use case for unit testing and recommended I should look into it. I found a few posts showing how to do it and I got a very basic test working(with a few numbers), but I had a few questions about it while I was working on it. First of all, I noticed that there was some weird stuff going on with the package; VSCode was complaining that

Test.java is not on the classpath of project InfiniteRecharge, only syntax errors are reported

and in addition, it did not seem to matter what the package actually was, it didn’t autocomplete and didn’t seem to mind when I changed it to something random. Is this expected? I also noticed that none of the JUnit classes autocompleted and nor did the import statements which leads me to believe that JUnit wasn’t recognized by IntelliSense, is there any way to fix this? The test also ran without the @Test annotation, I don’t know if it is simply good practice to put the annotation there or if it has any functional effect?

So apparently I had some really weird stuff going on with my .gitignore causing some build files to persist after being pushed to git which was causing loads of issues. The @Test annotation now works, packages now work and IntelliSense now works.


This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.