Multiple runwith for a junit test class

Does any one know how to tackle this.

@RunWith(SpringJUnit4ClassRunner.class)
@RunWith(Parametrized.class)

@ContextConfiguration("/META-INF/blah-spring-test.xml")
public class BlahTest
..

so i want to have a spring nature test and at the same time want to have it parameterized to avoid code duplication ...


You can't use two runners as it noted in the commented post. You should use the Parameterized runner as use Spring's TestContextManager to load the Spring context.

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

As of Spring Framework 4.2, JUnit-based integration tests can now be executed with JUnit rules instead of the SpringJUnit4ClassRunner . This allows Spring-based integration tests to be run with alternative runners like JUnit's Parameterized or third-party runners such as the MockitoJUnitRunner . See more details on spring doc.

链接地址: http://www.djcxy.com/p/82776.html

上一篇: 如何将npm / gulp / bower构建过程整合到sbt中?

下一篇: junit测试课的多个runwith