Spring Boot单元测试类

添加依赖


        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <version> 1.5.1.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-test</artifactId>
            <version>4.3.6.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version> 4.12</version>
        </dependency>

@RunWith(SpringJUnit4ClassRunner.class)
                     //SpringBoot启动类
@SpringBootTest(classes = SpringCloudApiGatewayApplication.class)
public class Test1 {


      @Autowired
      RedisMapper redisMapper;



      @Test
      public void Test(){

            Long time1=System.currentTimeMillis();
            for(int i=1;i<1000;i++){
                  //boolean flag=redisMapper.freControlTwo();
                  boolean flag=redisMapper.freControlOne();
                  Long time2=System.currentTimeMillis();
                  System.out.println("1"+flag);
                  System.out.println("time= "+(time2-time1));
            }


      }


      @Test
      public void Test2(){
           System.out.println(redisMapper.hasKey("getTime_2018-06-13"));
      }



      @Test
      public void remove(){

            redisMapper.delete("getTime_2018-06-13");
            redisMapper.delete("getTime_"+100);
      }
}
阅读更多
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/didi7696/article/details/80689377
个人分类: SpringBoot
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭
关闭