public class WebAPITestCase extends AbstractTestNGSpringContextTests{.....}
I was trying to understand what this means extends AbstractTestNGSpringContextTests.
How does it work and what is the use of it?
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.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.