Suite parameters
In the preceding example, there were parameters added at the <test>
section level. Parameters can also be added elsewhere, such as at the suite or class levels. These TestNG parameters can be processed using one of the setup or teardown methods and the @Parameters
annotation. Any number of parameters can be added, and it's useful for processing system properties or environment variables, default settings, browser or mobile preferences, and so on.
@Parameters
Let's say you want to run a test suite against a specific browser, platform, and environment, then re-run it on a different browser and platform. Using TestNG's @Parameters
allows you to change the settings in the suite XML file and process them in the setup class. Where you process them depends on when you want to invoke the browser or mobile device.
Using the previous example, we added them to the <test>
section of the suite file, so the driver will be created before any of the test classes are run. So in...