蘋果市值蒸發 843 億美元背後:店大欺客,還是扮豬吃老虎
阿新 • • 發佈:2021-09-15
新增依賴
<properties>
<mockito.version>2.23.0</mockito.version>
</properties>
<!--mockito-->
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>${mockito.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
<version>${mockito.version}</version>
<scope>test</scope>
</dependency>
測試類
public class XxxServiceImplTest { @InjectMocks private SC001ServiceImpl sC001ServiceImpl; @Mock private LA_MF_AbnormalMapper laMfAbnormalMapper; @Mock private ScenicMapper scenicMapper; @Before public void init() throws Exception { MockitoAnnotations.initMocks(this); } @Test public void getInterpretDataTest(){ when(laMfAbnormalMapper.getAllAbnormalNumByYesterday(null)).thenReturn(allAbnormalNum); when(laMfAbnormalMapper.getAbnormalByDate("")).thenReturn(average); Result result = sC001ServiceImpl.getInterpretData(filter); Assert.assertNotNull(result.getData()); } @Testpublic void getAbnormalEventSTest(){ when(laMfAbnormalMapper.getAllAbnormalByScenicId(any())).thenReturn(num); Result t = sC001ServiceImpl.getAbnormalEventS(filter); Assert.assertNotNull(t.getData()); }
其他
@value解決
ReflectionTestUtils.setField(la_mf_003_drService,"prefixUrl","hehehhehelala");