ArgumentAttribute クラス

説明

キーワード駆動テストのキーワードとしてマークされるメソッドの引数の名前を明示的に指定するために使用されます。

構文

C#
[AttributeUsageAttribute(AttributeTargets.Parameter)]
public class ArgumentAttribute : Attribute
VB
<AttributeUsageAttribute(AttributeTargets.Parameter>
Public Class ArgumentAttribute Inherits Attribute

プロパティ

名前 説明
Name プロパティ (ArgumentAttribute) 引数の名前を取得します。

例:2 つの引数を持つキーワードの作成

引数 username および password を持つ Login キーワードを作成するには、次のサンプル コードを使用します。

C#
[Keyword]
public void Login([Argument("Name of the user")] string username, [Argument("Password of the user")] string password) {
  // keyword implementation
}
VB
<Keyword()>
Public Sub Login(<Argument("Name of the user")> username As String, <Argument("Password of the user")> password As String)
  ' keyword implementation
End Sub

例:説明のない引数の使用

引数の説明を使用せずに、引数 username および password を持つ Login キーワードを作成するには、次のサンプル コードを使用します。

C#
[Keyword]
public void Login(string username, string password) {
  // keyword implementation
}
[Keyword]
public void Login([Argument] string username, [Argument] string password) {
  // keyword implementation
}
VB
<Keyword()>
Public Sub Login(username As String, password As String)
  ' keyword implementation
End Sub
<Keyword()>
Public Sub Login(<Argument> username As String, <Argument> password As String)
  ' keyword implementation
End Sub