需要引用的依赖:
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
maven依赖为:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>3.2.3.RELEASE</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration({ "classpath:applicationContext-springService.xml" })
public class DistributeServiceTest {
@Resource
DistributeService distributeService;
@Test
public void testGetStatisticsByChannel() {
long beginTime = 0;
long endTime = 1545615321794L;
List<Distribute> distributeInfo = new ArrayList<>(3);
Distribute distribute = new Distribute();
distribute.setChannelNo("1055100004");
distributeInfo.add(distribute);
distributeService.getStatisticsByChannel(distributeInfo, beginTime, endTime);
Assert.assertTrue(distributeInfo.get(0).getAndroidTotal().equals("3"));
}
@Test
public void test() {
System.out.println(123);
}
}