同时使用SpringJUnit4ClassRunner和Parameterized进行参数化

标题实际上是个不可能完成的任务,因为我们只能用一个Runwith注解,而且只能写一个类,但是我们可以曲线救国,插入下方的5到14行就可以注入了

 1 @ContextConfiguration(classes = { XXXX.class })
 2 @RunWith(Parameterized.class)
 3 public class XXXXTest {
 4 
 5     private TestContextManager testContextManager;
 6     @Before
 7     public void setUp() {
 8         testContextManager = new TestContextManager(getClass());
 9         try {
10             testContextManager.prepareTestInstance(this);
11         } catch (Exception e) {
12             e.printStackTrace();
13         }
14     }
15 
16     @Test
17     public void XXXXTest() {
18      //你的测试逻辑
19     }
20 }
原文地址:https://www.cnblogs.com/haorui/p/9177053.html