dubbo单元测试分两种情况
@Autowired注解是启动上下文环境,使用上下文对象进行测试,适合调试代码
@InjectMocks注解是启动上下文环境,使用mock对象替换上下文对象,适合单元测试
BaseTest
**
* Created by Luohh on 2023/2/10
*/
@Slf4j
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration({"classpath*:app_config/*.xml", "classpath*:dubbo_config/*.xml"})
public abstract class BaseTest extends AbstractJUnit4SpringContextTests {
}
?XXXXXTest
/**
* Created by Luohh on 2023/12/10
*/
@Slf4j
public class VideoServiceTest extends BaseTest {
@Autowired
private VideoService videoService;
@Autowired
private SpringTask springTask;
@Test
public void screenshotTaskTest() {
long userId = 5139L;
int type=2; //1压缩 2截图
boolean result = videoService.addFfmpegTask(userId,type);
springTask.screenshotTask();
Assert.assertNotNull("solrService.query() failed!", result);
}
}