TestMethodAttribute Klasa
Definicja
Ważne
Niektóre informacje odnoszą się do produktu w wersji wstępnej, który może zostać znacząco zmodyfikowany przed wydaniem. Firma Microsoft nie udziela żadnych gwarancji, jawnych lub domniemanych, w odniesieniu do informacji podanych w tym miejscu.
Ten atrybut służy do oznaczania metod testowych.
[System.AttributeUsage(System.AttributeTargets.Method, AllowMultiple=false)]
public class TestMethodAttribute : Attribute
[System.AttributeUsage(System.AttributeTargets.Method)]
public class TestMethodAttribute : Attribute
[System.AttributeUsage(System.AttributeTargets.Method, Inherited=false)]
[System.Runtime.CompilerServices.Nullable(0)]
public class TestMethodAttribute : Attribute
[System.AttributeUsage(System.AttributeTargets.Method, Inherited=false)]
public class TestMethodAttribute : Attribute
[System.AttributeUsage(System.AttributeTargets.Method, AllowMultiple=false)]
public sealed class TestMethodAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.Method, AllowMultiple=false)>]
type TestMethodAttribute = class
inherit Attribute
[<System.AttributeUsage(System.AttributeTargets.Method)>]
type TestMethodAttribute = class
inherit Attribute
[<System.AttributeUsage(System.AttributeTargets.Method, Inherited=false)>]
[<System.Runtime.CompilerServices.Nullable(0)>]
type TestMethodAttribute = class
inherit Attribute
[<System.AttributeUsage(System.AttributeTargets.Method, Inherited=false)>]
type TestMethodAttribute = class
inherit Attribute
Public Class TestMethodAttribute
Inherits Attribute
Public NotInheritable Class TestMethodAttribute
Inherits Attribute
- Dziedziczenie
-
TestMethodAttribute
- Pochodne
- Atrybuty
Uwagi
- W przypadku używania innych atrybutów, takich jak DataRowAttribute lub DynamicDataAttribute, użycie elementu TestMethodAttribute jest nadal wymagane.
- Metody testowe muszą być następujące:
- publiczne lub, jeśli DiscoverInternalsAttribute jest używany, może być wewnętrzny.
- nie statyczne
- nieogólne
- nie abstrakcja
- zwracany typ to
void, lub TaskValueTask. Jeślivoidparametr to , nie powinien to byćasync.
Konstruktory
| Nazwa | Opis |
|---|---|
| TestMethodAttribute() |
Inicjuje nowe wystąpienie klasy TestMethodAttribute. |
| TestMethodAttribute(String, Int32) |
Inicjuje nowe wystąpienie klasy TestMethodAttribute. |
| TestMethodAttribute(String) |
Inicjuje nowe wystąpienie klasy TestMethodAttribute. |
Właściwości
| Nazwa | Opis |
|---|---|
| DeclaringFilePath |
Pobiera ścieżkę pliku, która deklaruje atrybut. |
| DeclaringLineNumber |
Pobiera numer wiersza, który DeclaringFilePath deklaruje atrybut . |
| DisplayName |
Pobiera lub ustawia nazwę wyświetlaną testu. |
| UnfoldingStrategy |
Pobiera lub ustawia strategię rozwoju sparametryzowanych testów. |
Metody
| Nazwa | Opis |
|---|---|
| Execute(ITestMethod) |
Wykonuje metodę testową. |
| ExecuteAsync(ITestMethod) |
Wykonuje metodę testową. |