Skip to content

Bump test project dependencies #383

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

Merged
merged 4 commits into from
Jan 31, 2023
Merged

Conversation

dougbu
Copy link
Contributor

@dougbu dougbu commented Jan 30, 2023

Bump test project dependencies

  • Castle.Core, Moq, and xUnit versions were all out of date
  • hold xunit.runner.visualstudio version back in .NET SDK test projects
    • can be moved to latest version after we stop testing on netcoreapp2.1
  • add missing xunit.analyzers reference to System.Web.Razor.Test project
  • move all test projects to .NET v4.6.2 (a supported framework)
    • remove netstandard reference in System.Net.Http.Formatting.Test; not needed w/ new TFM & updated references
  • further separate build of Microsoft.TestCommon project when invoked from NetCore.Test project
    • special case RestorePackages for this case
    • add System.Net.Http references to avoid conflicting versions e.g. src/ and test/ TFMs differ

React to changed xUnit APIs

  • adjust Microsoft.TestCommon code
  • nit: use Array.Empty<byte>() in TranscodingStreamTests
    • TranscodingStream internals can be private instead

Resolve xUnit issues new analyzers find

React to new Moq changes

  • avoid ProtectedMock\1.ThrowIfPublicMethod(...) throw`ing
    • use new overloads introduced in the Moq 4.11.0 release
  • adjust to Moq hiding the ObjectProxy type better
  • update ControllerContext mocking to avoid NREs
    • setting HttpContext.User on the Object left get value null (did nothing)
  • nit: use SetupGet(...) for another property

- Castle.Core, Moq, and xUnit versions were all out of date
- hold xunit.runner.visualstudio version back in .NET SDK test projects
  - can be moved to latest version after we stop testing on netcoreapp2.1
- add missing xunit.analyzers reference to System.Web.Razor.Test project
- move all test projects to .NET v4.6.2 (a supported framework)
  - remove `netstandard` reference in System.Net.Http.Formatting.Test; not needed w/ new TFM & updated references
- further separate build of Microsoft.TestCommon project when invoked from NetCore.Test project
  - special case `RestorePackages` for this case
  - add System.Net.Http references to avoid conflicting versions e.g. src/ and test/ TFMs differ
- adjust Microsoft.TestCommon code
- nit: use `Array.Empty<byte>()` in `TranscodingStreamTests`
  - `TranscodingStream` `internal`s can be `private` instead
- address xUnit2000 warnings
  - pass expected values to `Assert.Equal(...)` as correct (left) argument
- make generic method types explicit to avoid
  `error CS0121: The call is ambiguous between the following methods or properties: ...`
- note: cannot remove unnecessary xUnit1013 suppression
  - related bug (xunit/xunit#1466) apparently not fixed in 1.0.0 analyzers package
  - was xunit/xunit.analyzers#82 fix (in 2017) insufficient?
- avoid `ProtectedMock\`1.ThrowIfPublicMethod(...)` `throw`ing
  - use new overloads introduced in the Moq 4.11.0 release
- adjust to Moq hiding the `ObjectProxy` type better
- update `ControllerContext` mocking to avoid NREs
  - setting `HttpContext.User` on the `Object` left `get` value `null` (did nothing)
- nit: use `SetupGet(...)` for another property
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\..\packages\xunit.runner.visualstudio.2.3.1\build\net20\xunit.runner.visualstudio.props" Condition="Exists('..\..\packages\xunit.runner.visualstudio.2.3.1\build\net20\xunit.runner.visualstudio.props')" />
<Import Project="..\..\packages\xunit.core.2.3.0\build\xunit.core.props" Condition="Exists('..\..\packages\xunit.core.2.3.0\build\xunit.core.props')" />
<Import Project="..\..\packages\xunit.runner.visualstudio.2.4.5\build\net462\xunit.runner.visualstudio.props" Condition="Exists('..\..\packages\xunit.runner.visualstudio.2.4.5\build\net462\xunit.runner.visualstudio.props')" />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be straightforward to parameterize versions in this repo? Would make future changes easier. But if it's pretty involved then it's probably not worth it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be fairly involved because packages.config files can't use msbuild variables. Therefore, not worthwhile.

In addition, it's worth doing these changes manually (well, w/ a careful regular expression or two 😉) because it gives us an opportunity to check the assembly paths (in case new assemblies are available).

@@ -9,15 +9,22 @@
<DefineConstants>$(DefineConstants);NETFX_CORE</DefineConstants>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>

<!-- Version 2.4.5 does not support netstandard2.1. -->
<_VSRunnerVersion Condition=" '$(TargetFramework)' == 'netcoreapp2.1' ">2.4.3</_VSRunnerVersion>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just use 2.4.3 everywhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My aim is to use the latest versions everywhere I could. I also plan to expand the testing matrix to include net6.0 and / or net7.0. Bottom line, netcoreapp2.1 is a special case and I'd rather make that clear.

Copy link
Contributor

@wtgodbe wtgodbe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MSBuild changes look reasonable

@dougbu dougbu merged commit 169d95f into aspnet:main Jan 31, 2023
@dougbu dougbu deleted the dougbu/bump.xunit.versions branch January 31, 2023 04:52
@dougbu dougbu added this to the 3.3.0 (5.3.0) milestone Feb 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants