Top Description Methods
org.testng.annotations

public @Interface Optional

extends Annotation
Annotations
@Retention:RUNTIME
@Target:PARAMETER
Static Imports
java.lang.annotation.ElementType.PARAMETER, .RetentionPolicy.RUNTIME

Specifies that the current parameter is optional. TestNG will pass in a specified default value, or null if none is specified.

Method Summary

Modifier and TypeMethod and Description
public String

Returns:

the value (default NULL_VALUE)
value
()

The default value to pass to this parameter.

Inherited from java.lang.annotation.Annotation:
annotationTypeequalshashCodetoString

Method Detail

valueback to summary
public String value()

The default value to pass to this parameter.

The default deserves a bit of explanation. JSR-175 (which defines annotations) says that Java annotation parameters can only be ConstantExpressions, which can be primitive/string literals, but not null.

In this case, we use this string as a substitute for null; in practice, TestNG will pass null to your code, and not the string "null", if you do not specify a default value here in this parameter.

Returns:String

the value (default NULL_VALUE)