案發現場
@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
, 這樣就會導致報錯