Skip to content

AbstractTestNGSpringContextTests: Spring beans not available within @BeforeTest methods [SPR-5404] #10077

@spring-projects-issues

Description

@spring-projects-issues

CN Yee opened SPR-5404 and commented

Spring beans are not available within @BeforeTest methods with TestNG tests, as follows:

@ContextConfiguration("/applicationContext.xml")
public class Testing extends AbstractTestNGSpringContextTests {

	@Autowired
	SessionFactory sessionFactory;

	@Test
	public void testMe() {
		Session s = sessionFactory.openSession(); // This is OK
	}
	
	@BeforeTest  
	public void beforeTest() {
        	 Session s = sessionFactory.openSession(); // This give NullPointerException
	}
}

Affects: 2.5.6, 3.0.5

Issue Links:

5 votes, 4 watchers

Metadata

Metadata

Assignees

Labels

in: testIssues in the test modulestatus: duplicateA duplicate of another issue

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions