Package org.testng.annotations
Annotation Interface BeforeMethod
-
Optional Element Summary
Modifier and TypeOptional ElementDescriptionboolean
For before methods (beforeSuite, beforeTest, beforeTestClass and beforeTestMethod, but not beforeGroups): If set to true, this configuration method will be run regardless of what groups it belongs to.String[]
The list of groups this method depends on.String[]
The list of methods this method depends on.The description for this method.boolean
Whether methods on this class/method are enabled.boolean
If true and the @Test method about to be run has an invocationCount > 1, this BeforeMethod will only be invoked once (before the first test invocation).String[]
The list of groups this class/method belongs to.boolean
boolean
If true, this @Configuration method will belong to groups specified in the @Test annotation on the class (if any).String[]
Causes this method to be invoked only if the test method belongs to a listed group.long
The maximum number of milliseconds this method should take.
-
Element Details
-
enabled
boolean enabledWhether methods on this class/method are enabled.- Returns:
- the value (default true)
- Default:
- true
-
groups
String[] groupsThe list of groups this class/method belongs to. Note that even if the test method being invoked belongs to a different group, all @BeforeMethod methods will be invoked before it as long as they belong to groups that were selected to run at all. SeeonlyForGroups()
to select test method groups which this method will be invoked before.- Returns:
- the value
- Default:
- {}
-
dependsOnGroups
String[] dependsOnGroupsThe list of groups this method depends on. Every method member of one of these groups is guaranteed to have been invoked before this method. Furthermore, if any of these methods was not a SUCCESS, this test method will not be run and will be flagged as a SKIP.- Returns:
- the value
- Default:
- {}
-
dependsOnMethods
String[] dependsOnMethodsThe list of methods this method depends on. There is no guarantee on the order on which the methods depended upon will be run, but you are guaranteed that all these methods will be run before the test method that contains this annotation is run. Furthermore, if any of these methods was not a SUCCESS, this test method will not be run and will be flagged as a SKIP.If some of these methods have been overloaded, all the overloaded versions will be run.
- Returns:
- the value
- Default:
- {}
-
onlyForGroups
String[] onlyForGroupsCauses this method to be invoked only if the test method belongs to a listed group. It can be used if different setups are needed for different groups. Omitting this or setting it to an empty list will cause this method to run before every test method, regardless of which group it belongs to. Otherwise, this method is only invoked if the test method being invoked belongs to one of the groups listed here.- Returns:
- the value
- Default:
- {}
-
alwaysRun
boolean alwaysRunFor before methods (beforeSuite, beforeTest, beforeTestClass and beforeTestMethod, but not beforeGroups): If set to true, this configuration method will be run regardless of what groups it belongs to.
For after methods (afterSuite, afterClass, ...): If set to true, this configuration method will be run even if one or more methods invoked previously failed or was skipped.- Returns:
- the value (default false)
- Default:
- false
-
inheritGroups
boolean inheritGroupsIf true, this @Configuration method will belong to groups specified in the @Test annotation on the class (if any).- Returns:
- the value (default true)
- Default:
- true
-
description
String descriptionThe description for this method. The string used will appear in the HTML report and also on standard output if verbose >= 2.- Returns:
- the value (default empty)
- Default:
- ""
-
firstTimeOnly
boolean firstTimeOnlyIf true and the @Test method about to be run has an invocationCount > 1, this BeforeMethod will only be invoked once (before the first test invocation).- Returns:
- the value (default false)
- Default:
- false
-
timeOut
long timeOutThe maximum number of milliseconds this method should take. If it hasn't returned after this time, this method will fail and it will cause test methods depending on it to be skipped.- Returns:
- the value (default 0)
- Default:
- 0L
-
ignoreFailure
boolean ignoreFailure- Returns:
- -
true
if the configuration failure arising out of this method should be ignored. Enabling this will override the "configfailurepolicy" set at the suite level ONLY for this method.
- Default:
- false
-