如何单元测试

IDE安装testng插件

自行百度

注意

(1)单元测试代码,建议放在
/dodo/src/test/java/com.dodo.testing.tests 目录下

(2)单元测试使用的配置文件位置
/dodo/src/test/resources

开始测试

package com.dodo.testing.tests;

import org.springframework.beans.factory.annotation.Autowired;
import org.testng.annotations.Test;

import com.dodo.common.framework.service.HqlHelperService;
import com.dodo.testing.DodoTestBase;
import com.pay.tenpay.PayConfig;
import com.third.aliyun.oss.OSSService;

/**
 * 
 * 单元测试示例
 * 
 */
// 单元测试类 继承 DodoTestBase 即可
public class ExampleTest extends DodoTestBase {

    // 注入被测对象
    @Autowired
    private OSSService       ossService;

    // 注入被测对象
    @Autowired
    private HqlHelperService helperService;

    // @Test 注解,开始测试
    @Test
    public void testConfig() {
        System.err.println("1:  " + PayConfig.getTenpayAccount("AccountB"));
        System.err.println("2:  " + ossService);
        System.err.println("3:  " + helperService);
        HqlHelper helper = HqlHelper.queryFrom(Province.class);
        helper.fetch(ProvinceFields.id, ProvinceFields.name).orderBy(ProvinceFields.name, OrderType.desc);
        Records records = helperService.getRecords(helper, Boolean.FALSE);
        records.forEach(record -> {
              System.err.println(record);
        });
    }
}
Copyright © Dodo Framework 2019 all right reservedModify At: 2019-12-12 16:16:16