Spring Dependency Injection with TestNG

前端 未结 3 557
难免孤独
难免孤独 2020-12-02 10:11

Spring support JUnit quite well on that: With the RunWith and ContextConfiguration annotation, things look very intuitive

@RunWith(         


        
3条回答
  •  [愿得一人]
    2020-12-02 10:54

    Here is an example that worked for me:

    import org.springframework.test.context.ContextConfiguration;
    import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;
    import org.testng.annotations.Test;
    
    @Test
    @ContextConfiguration(locations = {"classpath:applicationContext.xml"})
    public class TestValidation extends AbstractTestNGSpringContextTests {
    
        public void testNullParamValidation() {
            // Testing code goes here!
        }
    }
    

提交回复
热议问题