简单的自我练习测试直接依赖junit包用@Test注解就可以

@Test
public void test01(){
    System.out.println(11);
}

如果是实战项目里的单元测试,建议用以下方法:

1、写一个基础的测试类BaseTest,设定上下文的配置文件信息,指定运行环境

import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.web.WebAppConfiguration;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "classpath*:config/spring-*.xml" })
@WebAppConfiguration
public class BaseTest {

}

2、编写测试类进行测试

import com.hnac.hzinfo.flowable.dao.FlowableCustomSettingMapper;
import com.hnac.hzinfo.flowable.entity.FlowableCustomSetting;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Description: 测试类
 * @Author zhongyj
 * @Date 2020/3/11
 **/
public class MyFlowableTest extends BaseTest{

    @Autowired
    FlowableCustomSettingMapper settingMapper;

    @Test
    public void testUpdateBatch() throws Exception{
        Map<String, String> params = new HashMap<String, String>();

        List<FlowableCustomSetting> list = new ArrayList<>();
        FlowableCustomSetting s1 = new FlowableCustomSetting();
        s1.setActivityId("a1");
        s1.setSettingValue("val01");
        FlowableCustomSetting s2 = new FlowableCustomSetting();
        s2.setActivityId("a2");
        s2.setSettingValue("val02");
        list.add(s1);
        list.add(s2);

        int i = settingMapper.updateBatch(list);
        System.out.println("updateBatch结果:"+i);
    }

}