zl程序教程

您现在的位置是:首页 >  后端

当前栏目

同时使用Junit4的@Parameterized参数化测试和Spring容器

Spring测试容器 参数 同时 使用
2023-09-14 09:07:22 时间

同时使用Junit4的@Parameterized参数化测试和Spring容器整合


之剑 2016.4.30

整合Spring容器


@SpringApplicationConfiguration(classes = Application.class)
@WebAppConfiguration
public class TestBase {
   @Autowired
   protected TedaCaseService tedaCaseService;

   private TestContextManager testContextManager;

   @Before
   public void setUpContext() throws Exception {
      this.testContextManager = new TestContextManager(getClass());
      this.testContextManager.prepareTestInstance(this);
   }

}

Junit4的参数化测试

@RunWith(Parameterized.class):

package meeting.httpapi.test;

import com.teda.model.TedaCaseVo;
import meeting.TestBase;
import meeting.tool.SwordHttp;
import meeting.tool.TedaTool;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;

import java.uti