From cbb39f81571b2fd12b07d1b13cfbe5387aef3ce7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Amaury=20Lev=C3=A9?= Date: Tue, 9 Jul 2024 11:09:45 +0200 Subject: [PATCH 1/4] Add info about Microsoft.Testing.Platform.MSBuild and FAQ --- .../core/testing/unit-testing-platform-faq.md | 19 +++++++++++++++++++ .../testing/unit-testing-platform-intro.md | 11 +++++++++++ 2 files changed, 30 insertions(+) create mode 100644 docs/core/testing/unit-testing-platform-faq.md diff --git a/docs/core/testing/unit-testing-platform-faq.md b/docs/core/testing/unit-testing-platform-faq.md new file mode 100644 index 0000000000000..b16890bdf7dc8 --- /dev/null +++ b/docs/core/testing/unit-testing-platform-faq.md @@ -0,0 +1,19 @@ +--- +title: Microsoft.Testing.Platform FAQ +description: Get answers to frequently asked questions about Microsoft.Testing.Platform. +author: Evangelink +ms.author: amauryleve +ms.date: 07/09/2024 +--- + +# Microsoft.Testing.Platform FAQ + +This article contains answers to commonly asked questions about `Microsoft.Testing.Platform`. + +## error CS8892: Method 'TestingPlatformEntryPoint.Main(string[])' will not be used as an entry point because a synchronous entry point 'Program.Main(string[])' was found + +When you are manually defining an entry point (`Main`), there will be a conflict with the entry point generated by `Microsoft.Testing.Platform`. To avoid this issue you can either: + +- Disable the generation of the entry point by setting the following MSBuild property `false`. This is the most common scenario. + +- Fully disable the transitive dependency to `Microsoft.Testing.Platform.MSBuild` by setting the following MSBuild property `false`. Note that this is usually required only when you are referencing the test application from a non-test application (e.g. You have a console application referencing a test application). diff --git a/docs/core/testing/unit-testing-platform-intro.md b/docs/core/testing/unit-testing-platform-intro.md index a8ad609880785..24919d64b3c99 100644 --- a/docs/core/testing/unit-testing-platform-intro.md +++ b/docs/core/testing/unit-testing-platform-intro.md @@ -209,6 +209,17 @@ Specifies the minimum number of tests that are expected to run. By default, at l The directory where the test results are going to be placed. If the specified directory doesn't exist, it's created. The default is `TestResults` in the directory that contains the test application. +## MSBuild integration + +The NuGet package [Microsoft.Testing.Platform.MSBuild](https://www.nuget.org/packages/Microsoft.Testing.Platform.MSBuild) provides various integrations for `Microsoft.Testing.Platform` with MSBuild. + +- Support for `dotnet test`, see [dotnet test integration](./unit-testing-platform-integration-dotnet-test.md) for more information. +- Support for `ProjectCapability` required by `Visual Studio` and `Visual Studio Code` Test Explorers. +- Automatic generation of the entry point (`Main` method) + +> [!NOTE] +> This integration works in a transitive way (a project that references another project referencing this package will behave as if it references the package) and can be disabled through the `IsTestingPlatformApplication` MSBuild property. + ## See also - [Microsoft.Testing.Platform and VSTest comparison](unit-testing-platform-vs-vstest.md) From d655e094e16528df08c3a1a80880559f91980f93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Amaury=20Lev=C3=A9?= Date: Tue, 9 Jul 2024 11:46:36 +0200 Subject: [PATCH 2/4] Apply suggestions from code review --- docs/core/testing/unit-testing-platform-intro.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/core/testing/unit-testing-platform-intro.md b/docs/core/testing/unit-testing-platform-intro.md index 24919d64b3c99..722a484aa09ef 100644 --- a/docs/core/testing/unit-testing-platform-intro.md +++ b/docs/core/testing/unit-testing-platform-intro.md @@ -211,11 +211,12 @@ The directory where the test results are going to be placed. If the specified di ## MSBuild integration -The NuGet package [Microsoft.Testing.Platform.MSBuild](https://www.nuget.org/packages/Microsoft.Testing.Platform.MSBuild) provides various integrations for `Microsoft.Testing.Platform` with MSBuild. +The NuGet package [Microsoft.Testing.Platform.MSBuild](https://www.nuget.org/packages/Microsoft.Testing.Platform.MSBuild) provides various integrations for `Microsoft.Testing.Platform` with MSBuild: - Support for `dotnet test`, see [dotnet test integration](./unit-testing-platform-integration-dotnet-test.md) for more information. - Support for `ProjectCapability` required by `Visual Studio` and `Visual Studio Code` Test Explorers. - Automatic generation of the entry point (`Main` method) +- Automatic generation of the configuration file > [!NOTE] > This integration works in a transitive way (a project that references another project referencing this package will behave as if it references the package) and can be disabled through the `IsTestingPlatformApplication` MSBuild property. From 98fb4798955525b83128ad500d6a0e4767e1336d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Amaury=20Lev=C3=A9?= Date: Tue, 9 Jul 2024 12:38:00 +0200 Subject: [PATCH 3/4] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Jakub Jareš --- docs/core/testing/unit-testing-platform-faq.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/docs/core/testing/unit-testing-platform-faq.md b/docs/core/testing/unit-testing-platform-faq.md index b16890bdf7dc8..c222b8207d002 100644 --- a/docs/core/testing/unit-testing-platform-faq.md +++ b/docs/core/testing/unit-testing-platform-faq.md @@ -12,8 +12,10 @@ This article contains answers to commonly asked questions about `Microsoft.Testi ## error CS8892: Method 'TestingPlatformEntryPoint.Main(string[])' will not be used as an entry point because a synchronous entry point 'Program.Main(string[])' was found -When you are manually defining an entry point (`Main`), there will be a conflict with the entry point generated by `Microsoft.Testing.Platform`. To avoid this issue you can either: +Manually defining an entry point (`Main`) in test project, or referencing a test project into an application that already has an entry point, will result in conflict with the entry point generated by `Microsoft.Testing.Platform`. To avoid this issue take one of these steps: -- Disable the generation of the entry point by setting the following MSBuild property `false`. This is the most common scenario. +- Remove your manually defined entry point, typically `Main` method in `Program.cs`, and let testing platform to generate one for you. -- Fully disable the transitive dependency to `Microsoft.Testing.Platform.MSBuild` by setting the following MSBuild property `false`. Note that this is usually required only when you are referencing the test application from a non-test application (e.g. You have a console application referencing a test application). +- Disable the generation of the entry point by setting `false` MSBuild property. + +- Completely disable the transitive dependency to `Microsoft.Testing.Platform.MSBuild` by setting `false` MSBuild property. This is needed when you are referencing test project from a non-test project, for example: You have a console application referencing a test application. From 3ac944410b17cf70a750275ff2094a592f440e97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Amaury=20Lev=C3=A9?= Date: Tue, 9 Jul 2024 16:46:02 +0200 Subject: [PATCH 4/4] Update docs/core/testing/unit-testing-platform-faq.md Co-authored-by: David Pine --- docs/core/testing/unit-testing-platform-faq.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/core/testing/unit-testing-platform-faq.md b/docs/core/testing/unit-testing-platform-faq.md index c222b8207d002..7ca8ad233a777 100644 --- a/docs/core/testing/unit-testing-platform-faq.md +++ b/docs/core/testing/unit-testing-platform-faq.md @@ -14,7 +14,7 @@ This article contains answers to commonly asked questions about `Microsoft.Testi Manually defining an entry point (`Main`) in test project, or referencing a test project into an application that already has an entry point, will result in conflict with the entry point generated by `Microsoft.Testing.Platform`. To avoid this issue take one of these steps: -- Remove your manually defined entry point, typically `Main` method in `Program.cs`, and let testing platform to generate one for you. +- Remove your manually defined entry point, typically `Main` method in _Program.cs_, and let testing platform to generate one for you. - Disable the generation of the entry point by setting `false` MSBuild property.