testng@Test Annotation


Syntax

  • @Test
  • @Test(attribute1 = attributeValue, atrribute2 = attributeValue, etc)

Parameters

ParameterDetails
alwaysRunIf set to true, this test method will always be run even if it depends on a method that failed.
dataProviderThe name of the data provider for this test method.
dataProviderClassThe class where to look for the data provider. If not specified, the data provider will be looked on the class of the current test method or one of its base classes. If this attribute is specified, the data provider method needs to be static on the specified class.
dependsOnGroupsThe list of groups this method depends on.
dependsOnMethodsThe list of methods this method depends on.
descriptionThe description for this method.
enabledWhether methods on this class/method are enabled.
expectedExceptionsThe list of exceptions that a test method is expected to throw. If no exception or a different than one on this list is thrown, this test will be marked a failure.
groupsThe list of groups this class/method belongs to.
invocationCountThe number of times this method should be invoked.
invocationTimeOutThe maximum number of milliseconds this test should take for the cumulated time of all the invocationcounts. This attribute will be ignored if invocationCount is not specified.
priorityThe priority for this test method. Lower priorities will be scheduled first.
successPercentageThe percentage of success expected from this method
singleThreadedIf set to true, all the methods on this test class are guaranteed to run in the same thread, even if the tests are currently being run with parallel="methods". This attribute can only be used at the class level and it will be ignored if used at the method level. Note: this attribute used to be called sequential (now deprecated).
timeOutThe maximum number of milliseconds this test should take.
threadPoolSizeThe size of the thread pool for this method. The method will be invoked from multiple threads as specified by invocationCount. Note: this attribute is ignored if invocationCount is not specified