案发现场
@RunWith(SpringRunner.class)
@SpringBootTest
public class Test1 {
@Test
public void getLines() throws IOException, InterruptedException{
Cal cal = new CalImpl();
System.out.println(cal.add(1, 2));
}
}
解决方案
保证测试类所在的包被main
入口扫描到
比如:@ComponentScan
扫描的包是com.itplh
, 而单元测试的类所在包为org.itplh
, 这样就会导致报错