TestMethodAttribute Třída
Definice
Důležité
Některé informace platí pro předběžně vydaný produkt, který se může zásadně změnit, než ho výrobce nebo autor vydá. Microsoft neposkytuje žádné záruky, výslovné ani předpokládané, týkající se zde uváděných informací.
Tento atribut slouží k označení testovacích metod.
[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
- Dědičnost
-
TestMethodAttribute
- Odvozené
- Atributy
Poznámky
- Pokud používáte jiné atributy, jako DataRowAttribute je nebo DynamicDataAttribute, použití TestMethodAttribute je stále povinné.
- Testovací metody musí být:
- veřejné nebo pokud DiscoverInternalsAttribute se používá, může být interní.
- není statický
- není obecný
- není abstraktní
- návratový typ je buď
void, Tasknebo ValueTask. Pokudvoid, pak by nemělo býtasync.
Konstruktory
| Name | Description |
|---|---|
| TestMethodAttribute() |
Inicializuje novou instanci TestMethodAttribute třídy. |
| TestMethodAttribute(String, Int32) |
Inicializuje novou instanci TestMethodAttribute třídy. |
| TestMethodAttribute(String) |
Inicializuje novou instanci TestMethodAttribute třídy. |
Vlastnosti
| Name | Description |
|---|---|
| DeclaringFilePath |
Získá cestu k souboru, který deklaruje atribut. |
| DeclaringLineNumber |
Získá číslo řádku v rámci DeclaringFilePath deklaruje atribut. |
| DisplayName |
Získá nebo nastaví zobrazovaný název testu. |
| UnfoldingStrategy |
Získá nebo nastaví strategii pro rozbalení parametrizovaných testů. |
Metody
| Name | Description |
|---|---|
| Execute(ITestMethod) |
Spustí testovací metodu. |
| ExecuteAsync(ITestMethod) |
Spustí testovací metodu. |