1. Error information:
IDEA:
Java test class java.lang.nullpointerexception
2. Error reporting reason:
Without annotation, the unit test cannot call other classes in the project.
3. Error reporting solution:
These two annotations should be used above the test class:
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest
Similar Posts:
- [Solved] Cannot resolve symbol ‘SpringJUnit4ClassRunner’
- junitjava.lang.Exception: No tests found matching
- [Solved] Springboot test class injection bean is null Error: java.lang.NullPointerException…
- Springboot: solve the problem of failed to load ApplicationContext
- java.lang.Exception: No runnable methods
- javax.websocket.server.ServerContainer not available
- [Solved] Caused by: org.xml.sax.SAXParseException: Premature end of file.
- [Solved] Caused by: java.lang.ClassNotFoundException: org.mybatis.logging.LoggerFactory
- Solution to the problem of consider defining a bean of type ‘xxx’ in your configuration in spring boot auto injection
- [Solved] Springtest error: java.lang.nosuchmethoderror