Microsoft.VisualStudio.TestTools.UnitTesting 命名空間

類別

名稱 Description
AfterAssemblyCleanupEventArgs
AfterAssemblyInitializeEventArgs
AfterClassCleanupEventArgs
AfterClassInitializeEventArgs
AfterTestCleanupEventArgs
AfterTestInitializeEventArgs
ArchitectureConditionAttribute

此屬性用於忽略基於當前程序架構的測試類別或測試方法。

AssemblyCleanupAttribute

組裝清理屬性。

AssemblyFixtureProviderAttribute

表示指定FixtureType方法在每個消耗測試組件中註解AssemblyInitializeAttributeAssemblyCleanupAttribute或應被發現並執行一次,即使該方法未在該測試組件中宣告。

AssemblyInitializeAttribute

assembly initialize 屬性。

Assert

一組輔助類別,用於測試單元測試中的各種條件。 若未符合測試條件,則會拋出例外。

AssertExtensions

提供 Assert 類別的延伸。

AssertFailedException

AssertFailedException 類別。 用來表示測試案例的失敗。

AssertInconclusiveException

主張不確定的例外。

BaseShadow
BeforeAssemblyCleanupEventArgs
BeforeAssemblyInitializeEventArgs
BeforeClassCleanupEventArgs
BeforeClassInitializeEventArgs
BeforeTestCleanupEventArgs
BeforeTestInitializeEventArgs
CIConditionAttribute

此屬性用來條件性控制測試類別或測試方法是否執行或忽略,取決於該測試是否在 CI 環境中執行。

ClassCleanupAttribute

類別清理屬性。

ClassCleanupExecutionAttribute

關於何時執行類別清理方法的規範。

ClassInitializeAttribute

類別初始化屬性。

CollectionAssert

一組輔助類別,用來測試單元測試中集合相關的各種條件。 若未符合測試條件,則會拋出例外。

ConditionBaseAttribute

此屬性用於根據條件及可選訊息,條件控制測試類別或測試方法是否執行或忽略。

CssIterationAttribute

CSS 迭代 URI。

CssProjectStructureAttribute

CSS 專案結構 URI。

DataRowAttribute

屬性用來定義測試方法的內線資料。

DataSourceAttribute

指定連接字串、資料表名稱及資料驅動測試的列存取方法。

DataSourceElement

資料來源元素。

DataSourceElementCollection

資料來源元素集合。

DataTestMethodAttribute

此屬性目前與 N 沒有提供任何不同的功能 TestMethodAttribute。 它只是為了向下相容而存在。 即使是參數化測試,也建議使用 TestMethodAttribute

DeploymentItemAttribute

用於指定每次測試部署的部署項目(檔案或目錄)。 可以在測試類別或測試方法中指定。 可以有多個屬性實例來指定多個項目。 項目路徑可以是絕對路徑或相對路徑,若是相對路徑,則是相對於 RunConfig.RelativePathRoot。

DescriptionAttribute

測試說明。

DiscoverInternalsAttribute

測試組合中存在此屬性會使 MSTest 發現測試類別(即具有「TestClass」屬性的類別)及測試方法(即具有「TestMethod」屬性的方法),這些類別除了宣告公開的測試類別外,也為內部宣告。 當該屬性不存在於測試組件中時,該類別中的測試將無法被發現。

DoNotParallelizeAttribute

禁用平行化的規範。

DynamicDataAttribute

屬性定義測試方法的動態資料。

ExecutableConditionAttribute

此屬性用來條件控制測試類別或測試方法是否執行或忽略,取決於是否存在特定執行檔(工具)。

ExpectedExceptionAttribute

指定預期該類型例外的屬性。

ExpectedExceptionBaseAttribute

基底類別用於屬性,指定在單元測試中預期例外。

GenericParameterHelper

此類別旨在協助使用者進行使用泛型型別的單元測試。 GenericParameterHelper 滿足一些常見的通用型別約束,例如:

  1. 公開預設建構器
  2. 實作通用介面:IComparable、IEnumerable。
GitHubWorkItemAttribute

GitHubWorkItem 屬性;用於指定與此測試相關的 GitHub 問題。

GlobalTestCleanupAttribute

一個適用於組件中所有測試方法的全域測試清理屬性。 套用此屬性的方法必須是公開的、靜態的、非通用的,且只有一個類型的 TestContext 參數,並且要麼回傳 void 或 Task。

GlobalTestInitializeAttribute

一個適用於組裝中每個測試方法的全域測試初始化屬性。 套用此屬性的方法必須是公開的、靜態的、非通用的,且只有一個類型的 TestContext 參數,並且要麼回傳 void 或 Task。

HostTypeAttribute
IgnoreAttribute

此屬性用於忽略測試類別或測試方法,並附帶可選訊息。

InternalTestFailureException

InternalTestFailureException 類別。 用於表示測試案例的內部故障。

MemberConditionAttribute

根據一個或多個 staticBoolean 成員 Type (屬性、欄位或無參數方法)的值,條件式地執行或忽略一個測試類別或測試方法,這些成員由成員名稱引用。

OnTestStoppingEventArgs
OSConditionAttribute

此屬性用於忽略測試類別或測試方法,並附帶可選訊息。

OwnerAttribute

測試負責人。

ParallelizeAttribute

測試執行時的平行化等級規範。

PlannedTest

代表目前測試中計劃執行的單一測試(即已被發現並通過主動過濾器)。 回覆者 PlannedTests

PriorityAttribute

優先屬性;用來指定單元測試的優先順序。

PrivateObject

此類別代表系統中的活體 NON 公開 INTERNAL 物件

PrivateType

此類別代表私有存取器功能的私有類別。

RetryAttribute

此屬性用於在測試方法失敗時設定重試次數。

RetryBaseAttribute

一個抽象屬性,用來控制測試方法失敗時的重試。 由衍生類別來定義重試的方式。

RetryResult

這是測試重試的結果。

ShadowingAttribute
STATestClassAttribute

測試類別屬性。

STATestMethodAttribute

測試類別屬性。

StringAssert

弦斷言。

TestCategoryAttribute

TestCategory 屬性;用來指定單元測試的類別。

TestCategoryBaseAttribute

「Category」屬性的基底類別。

TestClassAttribute

此屬性用於標記測試類別。

TestClassExtensionAttribute
TestCleanupAttribute

測試清理屬性標記了標記為 TestMethodAttribute

TestConfiguration

支援測試的設定設定。

TestConfigurationSection

測試的配置區。

TestContext

用於儲存提供給單元測試的資訊。

TestDataRow<T>

當此類型從(例如經由 GetData(MethodInfo))返回DynamicDataAttribute時,它會判斷與特定測試案例相關的資訊。

TestDataSourceDiscoveryAttribute

說明如何發現 ITestDataSource 測試。

TestDataSourceOptionsAttribute

規範所有 ITestDataSource 現有組件的選項。

TestExecution
TestExecutionEventArgs
TestExtensionExecution
TestFilterContext

MSTest 暴露於 ITestFilter 單一測試的元資料快照。

TestFilterProviderAttribute

註冊使用者提供的 ITestFilter 實作,MSTest 介面卡會在每次即將執行的測試時呼叫該實作,且在已套用任何命令列過濾器(--filter如測試總管選擇等)後。

TestIdGenerationStrategyAttribute

規定如何產生測試 ID。

TestInitializeAttribute

測試初始化屬性。

TestMethodAttribute

此屬性用於標記測試方法。

TestMethodInvokerContext
TestMethodInvokerResult
TestPropertyAttribute

測試屬性。

TestRun

提供環境存取目前執行測試執行的資訊。

TimeoutAttribute

暫停屬性;用於指定單元測試的逾時時間。

UnitTestAssertException

Framework 例外的基底類別。

WebServiceHelper
WorkItemAttribute

WorkItem 屬性;用來指定與此測試相關的工作項目。

結構

名稱 Description
Assert.AssertAreEqualInterpolatedStringHandler<TArgument>

提供一個插值字串處理器, Assert.AreEqual 用於超載時,僅在斷言失敗時分配並格式化訊息。

Assert.AssertAreNotEqualInterpolatedStringHandler<TArgument>

提供一個插值字串處理器, Assert.AreNotEqual 用於超載時,僅在斷言失敗時分配並格式化訊息。

Assert.AssertAreNotSameInterpolatedStringHandler<TArgument>

提供一個插值字串處理器, Assert.AreNotSame 用於超載時,僅在斷言失敗時分配並格式化訊息。

Assert.AssertAreSameInterpolatedStringHandler<TArgument>

提供一個插值字串處理器, Assert.AreSame 用於超載時,僅在斷言失敗時分配並格式化訊息。

Assert.AssertCountInterpolatedStringHandler<TItem>

提供一個插值字串處理器HasCount<T>(Int32, IEnumerable<T>, Assert.AssertCountInterpolatedStringHandler<T>, String)IsEmpty<T>(IEnumerable<T>, Assert.AssertCountInterpolatedStringHandler<T>, String),僅在斷言失敗時分配並格式化訊息。

Assert.AssertGenericIsExactInstanceOfTypeInterpolatedStringHandler<TArg>

提供一個插值字串處理器, Assert.IsExactInstanceOfType 用於超載時,僅在斷言失敗時分配並格式化訊息。

Assert.AssertGenericIsInstanceOfTypeInterpolatedStringHandler<TArg>

提供一個插值字串處理器, Assert.IsInstanceOfType 用於超載時,僅在斷言失敗時分配並格式化訊息。

Assert.AssertGenericIsNotExactInstanceOfTypeInterpolatedStringHandler<TArg>

提供一個插值字串處理器, Assert.IsNotExactInstanceOfType 用於超載時,僅在斷言失敗時分配並格式化訊息。

Assert.AssertGenericIsNotInstanceOfTypeInterpolatedStringHandler<TArg>

提供一個插值字串處理器, Assert.IsNotInstanceOfType 用於超載時,僅在斷言失敗時分配並格式化訊息。

Assert.AssertIsExactInstanceOfTypeInterpolatedStringHandler

提供一個插值字串處理器, Assert.IsExactInstanceOfType 用於超載時,僅在斷言失敗時分配並格式化訊息。

Assert.AssertIsFalseInterpolatedStringHandler

提供一個插值字串處理器, Assert.IsFalse 用於超載時,僅在斷言失敗時分配並格式化訊息。

Assert.AssertIsInstanceOfTypeInterpolatedStringHandler

提供一個插值字串處理器, Assert.IsInstanceOfType 用於超載時,僅在斷言失敗時分配並格式化訊息。

Assert.AssertIsNotEmptyInterpolatedStringHandler<TItem>

提供一個插值字串處理器, Assert.IsNotEmpty 用於超載時,僅在斷言失敗時分配並格式化訊息。

Assert.AssertIsNotExactInstanceOfTypeInterpolatedStringHandler

提供一個插值字串處理器, Assert.IsNotExactInstanceOfType 用於超載時,僅在斷言失敗時分配並格式化訊息。

Assert.AssertIsNotInstanceOfTypeInterpolatedStringHandler

提供一個插值字串處理器, Assert.IsNotInstanceOfType 用於超載時,僅在斷言失敗時分配並格式化訊息。

Assert.AssertIsNotNullInterpolatedStringHandler

提供一個插值字串處理器, Assert.IsNotNull 用於超載時,僅在斷言失敗時分配並格式化訊息。

Assert.AssertIsNullInterpolatedStringHandler

提供一個插值字串處理器, Assert.IsNull 用於超載時,僅在斷言失敗時分配並格式化訊息。

Assert.AssertIsTrueInterpolatedStringHandler

提供一個插值字串處理器, Assert.IsTrue 用於超載時,僅在斷言失敗時分配並格式化訊息。

Assert.AssertNonGenericAreEqualInterpolatedStringHandler

提供一個插值字串處理器, Assert.AreEqual 用於超載時,僅在斷言失敗時分配並格式化訊息。

Assert.AssertNonGenericAreNotEqualInterpolatedStringHandler

提供一個插值字串處理器, Assert.AreNotEqual 用於超載時,僅在斷言失敗時分配並格式化訊息。

Assert.AssertNonStrictThrowsAsyncInterpolatedStringHandler<TException>

提供一個插值字串處理器, Assert.ThrowsAsync 用於超載時,僅在斷言失敗時分配並格式化訊息。

Assert.AssertNonStrictThrowsInterpolatedStringHandler<TException>

提供一個插值字串處理器, Assert.Throws 用於超載時,僅在斷言失敗時分配並格式化訊息。

Assert.AssertSingleInterpolatedStringHandler<TItem>

提供一個插值字串處理器, Assert.ContainsSingle 用於超載時,僅在斷言失敗時分配並格式化訊息。

Assert.AssertThrowsExactlyAsyncInterpolatedStringHandler<TException>

提供一個插值字串處理器, Assert.ThrowsExactlyAsync 用於超載時,僅在斷言失敗時分配並格式化訊息。

Assert.AssertThrowsExactlyInterpolatedStringHandler<TException>

提供一個插值字串處理器, Assert.ThrowsExactly 用於超載時,僅在斷言失敗時分配並格式化訊息。

RetryContext

代表測試重試的上下文。

TestFilterResult

結果僅以 a ITestFilter 判定,進行一次測試。

介面

名稱 Description
ITestDataSource

數據驅動測試的測試資料來源。

ITestDataSourceEmptyDataSourceExceptionInfo

自訂功能可選 ITestDataSource ,當資料來源未回傳資料列時,提供更豐富的資訊。 當資料來源實作此介面時,MSTest 會利用回傳的成員與型別名稱,建立一個更具可操作性的例外訊息,而非通用 GetData returned empty collection 訊息。

ITestDataSourceIgnoreCapability

指定測試資料來源可忽略的能力,並定義忽略原因。

ITestDataSourceUnfoldingCapability

規定測試資料來源有能力定義參數化測試應如何執行,無論是作為每個資料列的個別測試案例,還是作為單一測試案例。 這會影響測試結果以及測試的介面表示方式。

ITestFilter

由使用者提供的測試過濾器實作,該過濾器會依每個測試決定測試是否執行、靜默丟棄,或報告為跳過。

ITestMethod

用於執行的 TestMethod 。

ITestMethodInvoker
ITestRunInfo

關於目前測試執行的唯讀環境資訊。 透過 Current 存取。

列舉

名稱 Description
ClassCleanupBehavior

何時在測試執行時執行 ClassCleanup。

ConditionMode

一種用來 ConditionBaseAttribute 控制條件是否反轉的枚舉。

DataAccessMethod

在數據驅動測試中,如何存取資料列的枚舉。

DelayBackoffType

指定重試間隔的退回類型。

DynamicDataSourceType

Enum 用來指定資料是儲存在屬性、方法中還是欄位中。

ExecutionScope

平行執行模式。

InheritanceBehavior

繼承行為的枚舉,可用於 ClassInitializeAttribute 類別與 ClassCleanupAttribute 類別。 定義基底類別的 ClassInitialize 與 ClassCleanup 方法的行為。 列舉的類型必須相符。

MessageLevel

指定使用 DisplayMessage(MessageLevel, String) API 顯示訊息的嚴重程度等級。

OperatingSystems

一個用 OSConditionAttribute 來控制測試方法或測試類別支援或不支援哪些作業系統的枚舉。

SequenceOrder

指定在比較與 的 AreSequenceEqual<T>(IEnumerable<T>, IEnumerable<T>, SequenceOrder, String, String, String)集合時,序列元素是否必須以相同順序出現,或以任意順序出現。

TestArchitectures

一個用 ArchitectureConditionAttribute 來控制測試方法或測試類別支援或不支援哪些流程架構的枚舉。

TestDataSourceDiscoveryOption

支援測試的 ITestDataSource 發現模式。

TestDataSourceUnfoldingStrategy

規定參數化測試應如何執行,無論是作為每個資料列的獨立測試案例,或是單一測試案例。 這會影響測試結果以及測試的介面表示方式。

TestFilterAction

表示 MSTest 適配器應如何處理 回 ITestFilter 傳特定 TestFilterResult的測試。

TestIdGenerationStrategy

支援的測試ID產生策略。

TestTimeout

超時的列舉,可以用來搭配類別 TimeoutAttribute 使用。 列舉的類型必須相符。

UnitTestOutcome

單元測試結果。

委派

名稱 Description
BaseShadow.ElementConverter