Skip to content

Commit b9b3f85

Browse files
committed
Increas scope of PR
1 parent 71fc88f commit b9b3f85

6 files changed

+529
-367
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
title: Getting started with MSTest
3+
description: Learn about how to install MSTest.
4+
author: Evangelink
5+
ms.author: amauryleve
6+
ms.date: 07/24/2024
7+
---
8+
9+
# Getting started
10+
11+
MSTest functionality is split into multiple NuGet packages:
12+
13+
- [MSTest.TestFramework](https://www.nuget.org/packages/MSTest.TestFramework): Contains the attributes and classes that are used to define MSTest tests.
14+
- [MSTest.TestAdapter](https://www.nuget.org/packages/MSTest.TestAdapter): Contains the test adapter that discovers and runs MSTest tests.
15+
- [MSTest.Analyzer](https://www.nuget.org/packages/MSTest.Analyzer): Contains the analyzer that helps you write high-quality tests.
16+
17+
We recommend that you don't install these packages directly into your test projects. Instead, you should install either:
18+
19+
- [MSTest.Sdk](https://www.nuget.org/packages/MSTest.Sdk): A [MSBuild project SDK](/visualstudio/msbuild/how-to-use-project-sdk) that includes all the recommended packages and greatly simplifies all the boilerplate configuration. For more information, please refer to [MSTest SDK overview](./unit-testing-mstest-sdk.md).
20+
21+
- the [MSTest](https://www.nuget.org/packages/MSTest) metapackage, which includes all recommended packages: `MSTest.TestFramework`, `MSTest.TestAdapter`, `MSTest.Analyzer` and `Microsoft.NET.Test.Sdk`.
22+
23+
If you are creating a test infrastructure project that is intended to be used as an helper by multiple test projects, you should install the `MSTest.TestFramework` and `MSTest.Analyzers` packages directly into that project.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
title: Running MSTest tests
3+
description: Learn about how to run MSTest tests.
4+
author: Evangelink
5+
ms.author: amauryleve
6+
ms.date: 07/24/2024
7+
---
8+
9+
# Running tests
10+
11+
There are several ways to run MSTest tests depending on your needs. You can run tests from an IDE (e.g. Visual Studio, Visual Studio Code, Rider...), from the command line, or from a CI service (e.g. Azure DevOps).
12+
13+
Historically, MSTest relies on [VSTest](https://github.com/microsoft/vstest) for running tests in all contexts but starting with version 3.2.0, MSTest has its own [test runner](./unit-testing-mstest-runner-intro.md). This new runner is more lightweight and faster than VSTest, and it is the recommended way to run MSTest tests.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
---
2+
title: MSTest assertions
3+
description: Learn about MSTest assertions.
4+
author: Evangelink
5+
ms.author: amauryleve
6+
ms.date: 07/24/2024
7+
---
8+
9+
# Assertions
10+
11+
Use the Assert classes of the <xref:Microsoft.VisualStudio.TestTools.UnitTesting> namespace to verify specific functionality. A test method exercises the code of a method in your application's code, but it reports the correctness of the code's behavior only if you include Assert statements.
12+
13+
## Assertions exceptions
14+
15+
The <xref:Microsoft.VisualStudio.TestTools.UnitTesting.UnitTestAssertException> is the base of all assertion exceptions thrown by MSTest. If you write a new assert exception class, inherit from this base class to make it easier to identify the exception as an assertion failure instead of an unexpected exception thrown from your test or production code.
16+
17+
The <xref:Microsoft.VisualStudio.TestTools.UnitTesting.AssertFailedException> exception is thrown whenever a test fails. A test fails if it times out, throws an unexpected exception, or contains an assert statement that produces a **Failed** result.
18+
19+
The <xref:Microsoft.VisualStudio.TestTools.UnitTesting.AssertInconclusiveException> is thrown whenever a test produces an **Inconclusive** result. Typically, you add an <xref:Microsoft.VisualStudio.TestTools.UnitTesting.Assert.Inconclusive%2A?displayProperty=nameWithType> statement to a test that you are still working on, to indicate it's not yet ready to be run. This is also useful when you want to skip a test based on certain runtime conditions.
20+
21+
## The `Assert` class
22+
23+
In your test method, you can call any methods of the <xref:Microsoft.VisualStudio.TestTools.UnitTesting.Assert?displayProperty=fullName> class, such as <xref:Microsoft.VisualStudio.TestTools.UnitTesting.Assert.AreEqual%2A?displayProperty=nameWithType>. The <xref:Microsoft.VisualStudio.TestTools.UnitTesting.Assert> class has many methods to choose from, and many of the methods have several overloads.
24+
25+
## The `StringAssert` class
26+
27+
Use the <xref:Microsoft.VisualStudio.TestTools.UnitTesting.StringAssert> class to compare and examine strings. This class contains a variety of useful methods, such as <xref:Microsoft.VisualStudio.TestTools.UnitTesting.StringAssert.Contains%2A?displayProperty=nameWithType>, <xref:Microsoft.VisualStudio.TestTools.UnitTesting.StringAssert.Matches%2A?displayProperty=nameWithType>, and <xref:Microsoft.VisualStudio.TestTools.UnitTesting.StringAssert.StartsWith%2A?displayProperty=nameWithType>.
28+
29+
## The `CollectionAssert` class
30+
31+
Use the <xref:Microsoft.VisualStudio.TestTools.UnitTesting.CollectionAssert> class to compare collections of objects, or to verify the state of a collection.

0 commit comments

Comments
 (0)