Multiple runwith for a junit test class

maryoush

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 ...

John B

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);
}

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Multiple RunWith Statements in jUnit

Difference between running a test with RunWith(Junit4::class) annotation and without it

Equivalent for @RunWith(JUnitPlatform.class) for JUnit5

@RunWith(CucumberWithSerenity.class) throws NoClassDefFound cucumber/runtime/junit/Assertions

intellij junit @RunWith not resolved

JUnit Test for a Generic class

Junit test for model class

JUnit Test Class failure test

How to run some code before each JUnit @Test method individually, without using @RunWith nor AOP?

junit Test with SerenityParameterizedRunner in RunWith annotation: does not find tests (java.lang.Exception: No tests found matching Method)

@RunWith not compiling in JUnit5

Why does JUnit 4.12 throw a NoSuchMethodError for assertEquals when using @RunWith(SpringJUnit4ClassRunner.class)?

how to combine @RunWith with @RunWith(Parameterized.class)

Mocking a DateFormat class in junit test

Junit Test for Exception in a @InjectMocks class

Why is a class reloaded with a junit test?

Multiple Instances test using junit

Junit multiple setup and single test

Multiple Spring datasources for JUnit test

Test anonymous class in Junit or Groovy/Spock test

Finding the number of test methods in a JUnit test class

Why RunListener class testRunStarted() method calling multiple times for a single test in JUnit?

How do I execute multiple JUnit test suites from a single class?

@RunWith(PowerMockRunner.class) vs @RunWith(MockitoJUnitRunner.class)

@RunWith(SpringRunner.class) vs @RunWith(MockitoJUnitRunner.class)

how to write a junit test case for this class

How to test class which implements Runnable with Junit

Class-level test annotation in JUnit 5

JUnit how set up test class?