pom依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
</dependency>
单元测试
/**
* rabbit 生产消息单元测试
*/
@RunWith(SpringRunner.class)
@SpringBootTest
class RabbitMqControllerTest {
@Autowired
private RabbitTemplate rabbitTemplate;
@Test
public void simple() {
System.out.println("231e1231231");
rabbitTemplate.convertAndSend(RabbitConstant.SIMPLE_QUEUE_NAME, "hello world!");
}
文章介绍了在SpringBoot项目中使用`spring-boot-starter-test`进行单元测试,特别是针对RabbitMQ的生产消息功能,通过`@RunWith(SpringRunner.class)`和`@SpringBootTest`注解进行集成测试。
2万+

被折叠的 条评论
为什么被折叠?



