You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For more information about accessibility in Visual Studio, see [Accessibility tips and tricks](../ide/reference/accessibility-tips-and-tricks.md) and [How to: Use the keyboard exclusively](../ide/reference/how-to-use-the-keyboard-exclusively.md).
30
30
31
+
## Printable shortcut cheatsheet
32
+
33
+
Click to get our [printable keyboard shortcut cheatsheet for Visual Studio](https://visualstudio.microsoft.com/keyboard-shortcuts.pdf).
34
+
35
+
[:::image type="content" source="media/default-keyboard-shortcuts-in-visual-studio/visual-studio-keyboard-shortcut-cheatsheet.png" alt-text="Printable cheatsheet for keyboard shortcuts.":::](https://visualstudio.microsoft.com/keyboard-shortcuts.pdf)
36
+
31
37
<aname="popular"></a>
32
38
## Popular keyboard shortcuts for Visual Studio
33
39
@@ -1474,6 +1480,3 @@ The shortcuts specific to this context are:
Copy file name to clipboardExpand all lines: docs/ide/suggest-a-feature.md
-38Lines changed: 0 additions & 38 deletions
Original file line number
Diff line number
Diff line change
@@ -22,18 +22,6 @@ You can also start a feature suggestion directly from Visual Studio by choosing
22
22
23
23
Choosing **Provide a Suggestion** takes you to [Developer Community](https://aka.ms/feedback/suggest?space=8), where you can enter your suggestion.
24
24
25
-
## User Voice
26
-
27
-
Until now, Visual Studio users proposed new feature ideas on User Voice. By adding the *Suggest a feature* functionality to Developer Community, all of your feedback for the Visual Studio product team is now in one place.
28
-
29
-
The User Voice site has been made read-only. You can look back as you need to for context, but all new feature suggestions should be submitted on Developer Community.
30
-
31
-
We migrated an initial set of ideas from the User Voice forum to Developer Community. Migration was done based on the community impact of the feedback and our product roadmap priorities. If you were expecting to see a suggestion here that we may have missed, feel free to add it to Developer Community.
32
-
33
-
## Votes
34
-
35
-
The voting system in Developer Community is different to User Voice. To maintain the integrity of Developer Community vote counts and to avoid skewing of votes, we show the User Voice vote counts prominently as a tag next to each feature suggestion. As you continue to vote on suggestions in the enhanced Developer Community, your new vote counts will show separately from the User Voice vote counts.
36
-
37
25
## Suggestion status
38
26
39
27
After you submit a feature suggestion, states indicate where your feature submission is in its lifecycle. As we take your feedback into consideration and move it along the workflow, we tag it with the corresponding state. The various states associated with feature suggestions are listed here, along with a description of their meaning and color indicators.
@@ -103,32 +91,6 @@ Found the information we were looking for? You may request to reactivate the tic
103
91
104
92
- - -
105
93
106
-
## FAQ
107
-
108
-
### Why can't I see my User Voice idea in Developer Community?
109
-
110
-
New feature suggestions from the old User Voice forum have been migrated to Developer Community based on the impact to the broader community and our product road map priorities. If you think we've missed migrating your suggestion, add it as a new suggestion to Developer Community.
111
-
112
-
### Why have the votes not been carried over from User Voice?
113
-
114
-
The voting system in User Voice operates differently from the voting system in Developer Community. In the new system, we want to maintain the integrity of the vote counts and avoid skewing the data. We decided to show the User Voice vote counts prominently as a tag (instead of votes) for each suggestion. When users vote on suggest a feature submissions using Developer Community, the new votes will show separately from the User Voice votes.
115
-
116
-
### Where can I see comments associated with the suggestions imported from User Voice?
117
-
118
-
Follow the link we've included to go back to the User Voice comments on a suggestion that has been migrated to Developer Community. This link will be available during the transition period for easy reference if you need more context.
119
-
120
-
### Why can I see three vote counts for a suggestion?
121
-
122
-
When a suggestion has been imported from User Voice, you'll see three separate vote counts. The two vote counts shown as tags are the vote counts that the idea received originally on User Voice. The third vote count displayed to the left of the suggestion lets you see how many votes the suggestion is getting from Developer Community.
123
-
124
-
The voting system in User Voice operates differently from the votes in Developer Community. To maintain integrity of Developer Community vote counts and avoid skewing the data, we decided to show the User Voice vote counts prominently as a tag (instead of votes) for each suggestion.
125
-
126
-
### How long can I expect actions to take?
127
-
128
-
We're fully committed to listening to your feature suggestions and taking actions to provide valuable experiences to our customers. Actions on suggestions are prioritized based on impact to the broader community. Even if we can't respond personally to every suggestion, we'll make sure that your feedback gets to the right team and is evaluated carefully.
129
-
130
-
The response time depends on the status your feedback is in. Please review the explanation of statuses in this document to understand the response times.
131
-
132
94
## See also
133
95
134
96
-[Introducing 'Suggest a Feature' in Developer Community (Visual Studio blog)](https://devblogs.microsoft.com/visualstudio/introducing-suggest-a-feature-in-developer-community/?utm_source=vs_developer_news&utm_medium=referral)
MSBuild uses an XML-based project file format that's straightforward and extensible. The MSBuild project file format lets developers describe the items that are to be built, and also how they are to be built for different operating systems and configurations. In addition, the project file format lets developers author reusable build rules that can be factored into separate files so that builds can be performed consistently across different projects in the product.
67
67
68
+
The Visual Studio build system stores project-specific logic in the your project file itself, and uses imported MSBuild XML files with extensions like *.props* and *.targets* to define the standard build logic. The *.props* files define MSBuild properties, and *.targets* files define MSBuild targets. These imports are sometimes visible in the Visual Studio project file, but in newer projects such as .NET Core, .NET 5 and .NET 6 projects, you don't see the imports in the project file; instead, you see an SDK reference. These are called SDK-style projects. When you reference an SDK such as the .NET SDK, the imports of .props and .target files are implicitly specified by the SDK.
69
+
68
70
The following sections describe some of the basic elements of the MSBuild project file format. For a tutorial about how to create a basic project file, see [Walkthrough: Creating an MSBuild project file from scratch](../msbuild/walkthrough-creating-an-msbuild-project-file-from-scratch.md).
Copy file name to clipboardExpand all lines: docs/test/getting-started-with-unit-testing.md
+63-10Lines changed: 63 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
title: Get started with unit testing
3
3
description: Use Visual Studio to define and run unit tests to maintain code health, and to find errors and faults before your customers do.
4
4
ms.custom: SEO-VS-2020
5
-
ms.date: 12/22/2020
5
+
ms.date: 08/10/2021
6
6
ms.topic: tutorial
7
7
helpviewer_keywords:
8
8
- unit testing, create unit test plans
@@ -17,16 +17,17 @@ ms.workload:
17
17
18
18
Use Visual Studio to define and run unit tests to maintain code health, ensure code coverage, and find errors and faults before your customers do. Run your unit tests frequently to make sure your code is working properly.
19
19
20
-
In this article, the code and illustrations use C#, but the concepts and features apply to .NET languages, C++, Python, JavaScript, and TypeScript.
20
+
In this article, the code uses C# and C++, illustrations are in C#, but the concepts and features apply to .NET languages, C++, Python, JavaScript, and TypeScript.
21
21
22
22
## Create unit tests
23
23
24
24
This section describes how to create a unit test project.
25
25
26
26
1. Open the project that you want to test in Visual Studio.
27
27
28
-
For the purposes of demonstrating an example unit test, this article tests a simple "Hello World" C# project named **HelloWorldCore**. The sample code for such a project is as follows:
28
+
For the purposes of demonstrating an example unit test, this article tests a simple "Hello World" C# or C++ Console project named **HelloWorld** (**HelloWorldCore** in C#). The sample code for such a project is as follows:
29
29
30
+
### [.NET](#tab/dotnet)
30
31
```csharp
31
32
namespaceHelloWorldCore
32
33
@@ -39,14 +40,25 @@ This section describes how to create a unit test project.
39
40
}
40
41
```
41
42
43
+
### [C++](#tab/cpp)
44
+
```cpp
45
+
#include<iostream>
46
+
47
+
intmain()
48
+
{
49
+
std::cout << "Hello World!\n";
50
+
}
51
+
```
52
+
---
53
+
42
54
1. In **Solution Explorer**, select the solution node. Then, from the top menu bar, select **File** > **Add** > **New Project**.
43
55
44
-
1. In the new project dialog box, find a unit test project template for the test framework you want to use, such as MSTest, and select it.
56
+
1. In the new project dialog box, find a unit test project template for the test framework you want to use, such as MSTest (C#) or the **Native Unit Test** project (C++), and select it.
45
57
46
-
Starting in Visual Studio 2017 version 14.8, the .NET languages include built-in templates for NUnit and xUnit. For C++, you will need to select a test framework supported by the language. For Python, see [Set up unit testing in Python code](../python/unit-testing-python-in-visual-studio.md) to set up your test project.
58
+
Starting in Visual Studio 2017 version 14.8, the .NET languages include built-in templates for NUnit and xUnit. For C++, in this example select the **Native Unit Test** project, which uses Microsoft Native Unit Test Framework. (To use a different C++ test frameworks, see [Writing unit tests for C/C++](../test/writing-unit-tests-for-c-cpp.md)). For Python, see [Set up unit testing in Python code](../python/unit-testing-python-in-visual-studio.md) to set up your test project.
47
59
48
60
> [!TIP]
49
-
> For C#, you can create unit test projects from code using a faster method. For more information, see [Create unit test projects and test methods](../test/unit-test-basics.md#create-unit-test-projects-and-test-methods). To use this method with .NET Core or .NET Standard, Visual Studio 2019 is required.
61
+
> For C# only, you can create unit test projects from code using a faster method. For more information, see [Create unit test projects and test methods](../test/unit-test-basics.md#create-unit-test-projects-and-test-methods). To use this method with .NET Core or .NET Standard, Visual Studio 2019 is required.
50
62
51
63
The following illustration shows an MSTest unit test, which is supported in .NET.
52
64
@@ -78,7 +90,7 @@ This section describes how to create a unit test project.
78
90
79
91
1. Add code to the unit test method.
80
92
81
-
For example, you might use the following code by selecting the correct documentation tab that matches your test framework: MSTest, NUnit, or xUnit (supported on .NET only).
93
+
For example, you might use the following code by selecting the correct documentation tab that matches your test framework: MSTest, NUnit, or xUnit (supported on .NET only), or C++ Microsoft Unit Testing Framework.
82
94
83
95
### [MSTest](#tab/mstest)
84
96
@@ -170,6 +182,44 @@ This section describes how to create a unit test project.
170
182
}
171
183
```
172
184
185
+
### [Microsoft Native Unit Test Framework](#tab/msunittest)
186
+
187
+
```cpp
188
+
#include "pch.h"
189
+
#include "CppUnitTest.h"
190
+
#include "../HelloWorldUnitTestCPP/HelloWorldUnitTestCPP.cpp" // Update using your project name
191
+
192
+
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
193
+
194
+
namespace HelloWorldTests
195
+
{
196
+
TEST_CLASS(HelloWorldTests)
197
+
{
198
+
public:
199
+
200
+
TEST_METHOD(TestMethod)
201
+
{
202
+
std::string expected = "Hello World!\n";
203
+
204
+
std::stringstream buffer;
205
+
std::streambuf* sbuf = std::cout.rdbuf(); // Save cout's buffer
206
+
std::cout.rdbuf(buffer.rdbuf()); // Redirect cout to the stringstream buffer
207
+
208
+
// Call main() in your test
209
+
int result = main();
210
+
211
+
// When finished, redirect cout to the original buffer
212
+
std::cout.rdbuf(sbuf);
213
+
std::cout << "std original buffer: \n";
214
+
std::cout << buffer.get();
215
+
216
+
// Test
217
+
Assert::AreEqual(expected, buffer.str());
218
+
}
219
+
};
220
+
}
221
+
```
222
+
173
223
---
174
224
175
225
## Run unit tests
@@ -199,7 +249,7 @@ This section describes how to create a unit test project.
199
249
If you are using the MSTest, xUnit, or NUnit testing framework in Visual Studio 2017 or later, you can see live results of your unit tests.
You can run unit tests in Visual Studio by using third-party test frameworks such as NUnit, Boost, or Google C++ Testing Framework, depending on your programming language. To use a third-party framework:
231
281
232
282
- Use the **NuGet Package Manager** to install the NuGet package for the framework of your choice.
233
283
234
284
- (.NET) Starting in Visual Studio 2017 version 14.6, Visual Studio includes pre-configured test project templates for NUnit and xUnit test frameworks. The templates also include the necessary NuGet packages to enable support.
235
285
236
-
- (C++) InVisualStudio 2017 andlaterversions, someframeworkslikeBoostarealreadyincluded. Formoreinformation, see [WriteunittestsforC/C++ inVisualStudio](../test/writing-unit-tests-for-c-cpp.md).
286
+
- (C++) In Visual Studio 2017 and later versions, some frameworks like Google C++ Testing Framework are already included. For more information, see [Write unit tests for C/C++ in Visual Studio](../test/writing-unit-tests-for-c-cpp.md).
237
287
238
288
To add a unit test project:
239
289
@@ -280,3 +330,6 @@ To add a unit test project:
280
330
281
331
> [!div class="nextstepaction"]
282
332
> [Create and run unit tests for managed code](walkthrough-creating-and-running-unit-tests-for-managed-code.md)
333
+
334
+
> [!div class="nextstepaction"]
335
+
> [Write unit tests for C/C++](../test/writing-unit-tests-for-c-cpp.md)
0 commit comments