TestMethodAttribute Класс
Определение
Важно!
Некоторые сведения относятся к предварительной версии продукта, в которую до выпуска могут быть внесены существенные изменения. Майкрософт не предоставляет никаких гарантий, явных или подразумеваемых, относительно приведенных здесь сведений.
Этот атрибут используется для маркировки методов тестирования.
[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
- Наследование
-
TestMethodAttribute
- Производный
- Атрибуты
Комментарии
- При использовании других атрибутов, таких как DataRowAttribute или DynamicDataAttribute, использование TestMethodAttribute по-прежнему требуется.
- Методы тестирования должны быть:
- public или, если DiscoverInternalsAttribute используется, он может быть внутренним.
- не статический
- не универсальный
- не абстрактный
- Тип возвращаемого
voidзначения имеет значение , Taskили ValueTask. Еслиvoid, то это не должно бытьasync.
Конструкторы
| Имя | Описание |
|---|---|
| TestMethodAttribute() |
Инициализирует новый экземпляр класса TestMethodAttribute. |
| TestMethodAttribute(String, Int32) |
Инициализирует новый экземпляр класса TestMethodAttribute. |
| TestMethodAttribute(String) |
Инициализирует новый экземпляр класса TestMethodAttribute. |
Свойства
| Имя | Описание |
|---|---|
| DeclaringFilePath |
Возвращает путь к файлу, объявляющий атрибут. |
| DeclaringLineNumber |
Возвращает номер строки внутри DeclaringFilePath этого атрибута. |
| DisplayName |
Возвращает или задает отображаемое имя для теста. |
| UnfoldingStrategy |
Возвращает или задает стратегию развертывания параметризованных тестов. |
Методы
| Имя | Описание |
|---|---|
| Execute(ITestMethod) |
Выполняет метод теста. |
| ExecuteAsync(ITestMethod) |
Выполняет метод теста. |