@ExtendWith(SpringRunner.class)
@SpringBootTest
@ContextConfiguration(classes= CommunityApplication.class)上面写着
不兼容类型。发现:'java.lang.Class',必需:'java.lang.Class<?扩展org.junit.jupiter.api.extension.Extension>[]‘
然后我在pom.xml中添加了代码:
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
<version>4.12</version>
</dependency>然后上面写着
包“junit:junit”可以升级到版本“4.13.2”
发布于 2022-09-27 08:20:14
我认为你在滥用注解。
@RunWith(SpringRunner.class)这个工具只是用来启用春季引导功能的。(@Autowire,@mockbean)它是连接单元测试和用于测试的弹簧引导测试特性之间的桥梁。当您需要测试那些Spring相关元素时,可以使用这个注释。
@SpringBootTest --这个是用于集成测试的。它加载一个完整的应用程序上下文,用于端到端的测试。
您没有将这两个注释混在一起。
https://stackoverflow.com/questions/73856859
复制相似问题