zoukankan      html  css  js  c++  java
  • spring boot项目测试类的使用

     1 package com.hut.maoyanmovie;
     2 
     3 import com.hut.maoyanmovie.bean.Orders;
     4 import com.hut.maoyanmovie.dao.OrdersMapper;
     5 import org.junit.jupiter.api.Test;
     6 import org.springframework.beans.factory.annotation.Autowired;
     7 import org.springframework.boot.test.context.SpringBootTest;
     8 import org.springframework.test.context.ActiveProfiles;
     9 
    10 @SpringBootTest
    11 @ActiveProfiles("dev")
    12 
    13 class MaoyanmovieApplicationTests {
    14     @Autowired(required = false)
    15     OrdersMapper ordersMapper;
    16 
    17     @Test
    18     void contextLoads() {
    19 
    20         ordersMapper.insertOrdersByOid(new Orders(9,5,5,"2020年12月09日"));
    21     }
    22 
    23 }

    一般是@Autowired注入,然后直接在void contextLoads()方法中直接调用要测试的方法即可

    比如上述直接测试

    insertOrdersByOid()方法
  • 相关阅读:
    5月27日
    5月26日
    5月25日
    5月24日
    5月22日
    梦断代码(3)
    01团队冲刺
    07周总结
    06周总结
    构建之法阅读笔记
  • 原文地址:https://www.cnblogs.com/cleanlife/p/14110133.html
Copyright © 2011-2022 走看看