I am testing my controller given below
@Controller
public class MasterController {
@GetMapping(\"/\")
public String goLoginPage(){
return \"index\";
}
}
I had the same error, and found that when I had generated the project my pom.xml showed my groupId as com.example rather than with my actual domain:
I corrected the pom.xml to be:
Next, I changed the file structure from:
src/test/java/com/example
to src/test/java/com/mydomain
Last, I had to update the package declaration inside my
SampleProjectApplicationTest.java
file to match the correct file structure. Once that was all in place, the tests worked fine.
I am not sure how I ended up with com.example where the rest of my project was correct, but the fix was that simple in my case.
Hopefully this helps someone.