如何进行单元测试.md 1.2 KB

suite模式下如何进行单元测试

好处不说了

单元测试开发流程

  1. 确定需要测试的接口 Eval360RatingService#find360Score
  2. tip-front模块的src/test/java目录下新建对应的包 com.minto.app.performance.service.impl
  3. 在刚刚新建的包下新建Eval360RatingServiceImplTest测试类
  4. 该类需要继承TestCase基类

    import static org.junit.jupiter.api.Assertions.*;
    import com.minto.tip.test.TestCase;
       
    class Eval360RatingServiceImplTest extends TestCase {
    
       @Autowired
       private Eval360RatingService eval360RatingService;
    
       @Test
       void find360Score() throws BusinessException {
            // 测试接口
           assertTrue(CollectionUtil.isNotEmpty(eval360RatingService.find360Score(565640502972926771L,
               List.of(ResourceEnum.ResourceTypeEnum.OrgPerson.getResourceKey(9010535345073767852L)))));
       }
    }
    
  5. 运行测试

注意事项

  1. 单元测试的代码只能写在tip-front模块下,写在其他模块没有效果。
  2. 单元测试时也会启动整个环境,所以建议多个测试放在同一个测试类中进行测试