-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move shared unit test code to a shared assembly #9420
Conversation
There are also some code files with tests shared among multiple projects. For example, src/Shared/UnitTests/ErrorUtilities_Tests.cs is shared in the following test projects.
Is there any difference running the same set of tests in such a shared test code file multiple times in different projects? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are also some code files with tests shared among multiple projects. For example, src/Shared/UnitTests/ErrorUtilities_Tests.cs is shared in the following test projects.
- src\Build.UnitTests\Microsoft.Build.Engine.UnitTests.csproj
- src\Tasks.UnitTests\Microsoft.Build.Tasks.UnitTests.csproj
- src\Utilities.UnitTests\Microsoft.Build.Utilities.UnitTests.csproj
Is there any difference running the same set of tests in such a shared test code file multiple times in different projects?
I think this is because the code under test src/Shared/ErrorUtilities.cs
is compiled into several product assemblies, so it makes sense to test each of those assemblies. So let's leave it for now. However, as we move that stuff into Framework
, we can single-instance the tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love it!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Fixes #8364
Context
As the issue mentions /src/Shared/UnitTests shares functionality in unit tests via shared code files. Actually they should be moved to /src/UnitTests.Shared/Microsoft.Build.UnitTests.Shared.csproj
Changes Made
Assemble share code files with common functions in unit tests from /src/Shared/UnitTests into /src/UnitTests.Shared/Microsoft.Build.UnitTests.Shared.csproj
Testing
Notes