what is AbstractTestNGSpringContextTests

Please read the javadoc:

AbstractTestNGSpringContextTests is an abstract base test class that integrates the Spring TestContext Framework with explicit ApplicationContext testing support in a TestNG environment. When you extend AbstractTestNGSpringContextTests, you can access a protected applicationContext instance variable that you can use to perform explicit bean lookups or to test the state of the context as a whole.

Basically a spring application context will be setup for the test class.

If that still doesn't make sense I'd recommend you read this.


First, TestNG (stands for Test Next Generation) is a testing framework inspired from JUnit and NUnit but introducing some new functionalities that make it more powerful and easier to use like test that your code is multithread safe, powerful execution model, etc.

The class AbstractTestNGSpringContextTests includes the spring ApplicationContext. To make it available when executing TestNG test, AbstractTestNGSpringContextTests has methods annotated with TestNG annotations like @BeforeClass and @BeforeMethod.

So to have this functionality of running TestNG with Spring components, all it left to do is to extend AbstractTestNGSpringContextTests.

BTW, AbstractTransactionalTestNGSpringContextTests extends AbstractTestNGSpringContextTests. It not only provides transactional support but also has some convenience functionality for JDBC access.