O'Reilly logo

TestNg Beginner's Guide by Varun Menon

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 6. The Factory Annotation

In the previous chapter we learned about defining the dependency of tests on other tests or a group of tests. In this section we will learn about the @Factory annotation provided by TestNG. Factory allows tests to be created at runtime depending on certain datasets or conditions.

In this chapter we'll cover the following topics:

  • What is factory
  • Passing parameters to test classes
  • The DataProvider annotation with the @Factory annotation
  • The DataProvider or @Factory annotation
  • Dependency with the @Factory annotation

What is factory?

Sometimes we may need to run a set of tests with different data values. To achieve this we may define a separate set of tests inside a suite in the testng XML and test the required scenario. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required