Let me start by saying that I'm by no means proficient with using JUnit, so if my question makes no sense, I appreciate all comments I can get!
When I use Junit I set up the test class in its own package different than the package that has the actual code being tested. Then I setup the class that has the runner to run the test class in a different package. Recently I was told that I was creating unnecessary packages and if need be I can have all the classes (source and test) in the same package, and even have the runner in the test class' main method and run the test that way.
I tried variations of the above suggestion, but all I get is "no test executed for project"!
So is there some best practices for using and running JUnit or what?
Basically, you put all your production code under src/main/java and all your test classes in parallel packages under src/test/java. Maven/Gradle know how to compile and run the tests so that even if the source files are in different physical locations, as long as you use the same package structure they (the .class files) will effectively be in the same package. That means that tests will have at least package-private access to the production code.
The best ideas are the crazy ones. If you have a crazy idea and it works, it's really valuable.—Kent Beck