Skip to content
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

Add Windows.Markup tests #138

Merged
merged 2 commits into from
Sep 6, 2023
Merged

Add Windows.Markup tests #138

merged 2 commits into from
Sep 6, 2023

Conversation

hughbe
Copy link
Contributor

@hughbe hughbe commented Dec 10, 2018

Bunch of tests for attributes, ValueSerializer, event args, converters etc in the System.Windows.Markup namespace

Assistance required: wrote these on my mac, they pass :) but not sure how to integrate into CI

Planning on writing more for the remaining stuff soon!

/cc @karelz

@karelz
Copy link
Member

karelz commented Dec 10, 2018

@hughbe hold on for a few days please. Looks like WPF team has plans for tests and we want to make sure your effort aligns with them.
There are more existing tests to be open-sourced for conversion. There may be limitations on how many new tests to take, etc. (due to long runtimes, etc.)
Please give us few days to come up either with a plan or plan for a plan. Thanks!

@dotnet/wpf-developers

@hughbe
Copy link
Contributor Author

hughbe commented Dec 10, 2018

Okay no problem, from the readme:

We have published very few tests and have very limited coverage for PRs at this time as a result. We will add more tests in 2019, however, it will be a progressive process. We welcome test contributions to increase coverage and help us validate PRs more easily.

These tests are aimed at getting high coverage for simple attributes and classes used around System.Xaml. They’re unit, not integration tests and take a really short time running so runtime shouldn’t be an issue

@rladuca
Copy link
Member

rladuca commented Dec 16, 2018

@hughbe We're working on getting public test guidance out and having a plan for accepting great contributions like this. Apologies for not being completely prepared in this regard, we'll get there as soon as we can.

Just to be clear, we're not concerned with the runtimes of these specific tests. Generally, the full CI test suite also contains a good amount of GUI end to end testing. This is necessary to validate core functionality of the product. Unfortunately, the expected runtime of such a set of tests is around 15-20 minutes. So we're hesitant to add to this test corpus until we have a better idea of what sort of impact everything has all up.

That being said, our overall goal for testing is to port everything WPF has. Our feature tests are much larger (~24,000 tests total) and obviously can't be run as part of every CI build. So these will be added as a disjointed test set (we haven't decided exactly how just yet) that developers can use as we do internally to validate more technical changes and contribute new test coverage.

I'll be working on this plan and broader test porting in the coming weeks and I'll update dotnet/wpf-test#105 accordingly.

@hughbe hughbe force-pushed the attribute-tests branch 2 times, most recently from ea40a0b to 6428bd1 Compare December 23, 2018 10:07
@illialarka
Copy link

illialarka commented Jan 15, 2019

Hi, everyone!

Well, from this conversation I realized there is no published plan for testing, is not there? I would like to contribute to WPF test. Should I wait publishing of plans?

@rladuca
Copy link
Member

rladuca commented Jan 15, 2019

@illialarka Yes, please wait on the plan to be published. We've been going over a set of plans for both getting the current tests we have from desktop framework ported and also allowing contributions in the short term from the community. In the next 2 or 3 weeks, we hope to have the guidance sorted and published.

@hughbe
Copy link
Contributor Author

hughbe commented Apr 7, 2019

I'd like to move forward with this PR if there aren't any objections :)

Basically what I've done here is written unit tests that cover the classes found in the System.Windows.Markup namespace. For this reason I don't think it belongs in DRT tests, but rather in another test project. Following .NET Core open source conventions, I've named it System.Xaml.Tests.csproj.

I'm not sure whether this will automatically be run in the CI. I've tested it all locally, but thats something I'd appreciate a double check on that we run these unit tests in CI

@karelz
Copy link
Member

karelz commented Apr 7, 2019

Thanks for not giving up on this @hughbe!
@vatsan-madhavan is it something you would consider?

@grubioe grubioe added the PR metadata: Label to tag PRs, to facilitate with triage label May 28, 2019
@hughbe
Copy link
Contributor Author

hughbe commented Jun 26, 2019

Any progress with adding a unit test project for things like this?

@@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
Copy link
Contributor

Choose a reason for hiding this comment

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

can you name this file "System.Xaml.UnitTests.csproj". i think that way it get's automatically picked up and ran by arcade.

Copy link
Contributor

Choose a reason for hiding this comment

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

<ProjectReference Include="..\..\src\System.Xaml\System.Xaml.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="coverlet.msbuild" Version="2.4.0">
Copy link
Contributor

Choose a reason for hiding this comment

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

what is this package reference for? do other dotnet repos use this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah - its used for code coverage /cc @ViktorHofer

using System.Collections.Generic;
using Xunit;

namespace System.Xaml.Tests.Common
Copy link
Contributor

Choose a reason for hiding this comment

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

what makes these "Common"?

Copy link
Contributor

Choose a reason for hiding this comment

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

oh i see, they are test helper classes, i thought these were tests 😂

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What are your thoughts on using something like the Moq framework (like they use in winforms)

Would remove the need for this type of CustomXYZ class!

Copy link
Contributor

Choose a reason for hiding this comment

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

let me go take a look at how it's used in WinForms. just read the github page and it looks awesome!

Copy link
Contributor

Choose a reason for hiding this comment

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

I think I'm starting to understand how it's used, and that does look pretty nice! I think it'll be pretty clear if you're able to make a small change and push an update? Don't change everything to it just in case, but it looks fairly righteous

Copy link
Contributor

Choose a reason for hiding this comment

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

You'll need to push another change anyways to kick off another PR and CI run so we can see if the tests are running anyways :)

@stevenbrix
Copy link
Contributor

Any progress with adding a unit test project for things like this?

@hughbe I'm not sure, honestly this looks awesome and I love it. This is the direction we need our tests heading in. I'm going to queue up another build and will let you know if i see the tests running.

@ryalanms
Copy link
Member

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Base automatically changed from master to main March 17, 2021 17:38
@ryalanms ryalanms requested a review from a team as a code owner March 17, 2021 17:38
@pchaurasia14 pchaurasia14 added the Community Contribution A label for all community Contributions label Jul 20, 2022
@ghost ghost assigned hughbe Jul 20, 2022
@hughbe hughbe force-pushed the attribute-tests branch 2 times, most recently from b6caaf9 to a695515 Compare May 2, 2023 15:32
@hughbe
Copy link
Contributor Author

hughbe commented May 2, 2023

Have rebased this PR and would welcome feedback & perhaps @ViktorHofer's help on the first commit to make sure I've got the new test project set up correctly

@ViktorHofer
Copy link
Member

First commit looks good to me 👌


namespace System.Xaml.Tests.Common
{
public class CustomTypeDescriptorContext : ITypeDescriptorContext
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Could look to use Moq for these instead of direct subclasses

@hughbe
Copy link
Contributor Author

hughbe commented May 2, 2023

Thanks @ViktorHofer! So nothing else is required for these tests to run automatically in CI etc?

@hughbe
Copy link
Contributor Author

hughbe commented Jul 18, 2023

Quick point: It says: dotnet-wpf CI Successful in 20m — Build #20230717.2 had test failures , but the report is green

image

@singhashish-wpf
Copy link
Member

Quick point: It says: dotnet-wpf CI Successful in 20m — Build #20230717.2 had test failures , but the report is green

image

The failing tests are DRTs, As of now we aren't failing the builds due to failing DRTs. This will happen soon once we have all the DRTs in green state to have a baseline. We are in process of fixing the DRTs.
Regards
Ashish

@dipeshmsft
Copy link
Member

@hughbe, as of now your tests are not running on the CI. Since System.Xaml.Tests.csproj is not added in the Microsoft.Dotnet.Wpf.sln file, they are not being built and run.

@hughbe
Copy link
Contributor Author

hughbe commented Jul 25, 2023

OK we have it building, which is good!

Two errors, are they related?

C:\Program Files\Microsoft Visual Studio\2022\Preview\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2353,5): error MSB3270: (NETCORE_ENGINEERING_TELEMETRY=Build) There was a mismatch between the processor architecture of the project being built "MSIL" and the processor architecture of the reference "D:\a_work\1\s\artifacts\bin\System.Xaml\x64\Debug\net8.0\System.Xaml.dll", "AMD64". This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project.
C:\Program Files\Microsoft Visual Studio\2022\Preview\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2353,5): error MSB3270: (NETCORE_ENGINEERING_TELEMETRY=Build) There was a mismatch between the processor architecture of the project being built "MSIL" and the processor architecture of the reference "D:\a_work\1\s\artifacts\bin\System.Xaml\x64\Debug\net8.0\System.Xaml.dll", "AMD64". This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project.

image

The CI is acting up a bit showing which tests actually failed though
image

@dipeshmsft
Copy link
Member

Apart from the ones on the CI, take a look at the artifacts :
There in the log generated for the tests, we get the following error :

xUnit.net Console Runner v2.4.0 (64-bit .NET 8.0.0-preview.5.23280.8)
System.TypeLoadException: Could not load type 'System.Runtime.CompilerServices.NullableContextAttribute' from assembly 'System.Runtime, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.

@hughbe
Copy link
Contributor Author

hughbe commented Jul 25, 2023

Same error as dotnet/runtime#88518? /cc @ericstj

@@ -1910,6 +1920,22 @@ Global
{AF9084C3-BF37-4A56-A851-89F3BAE731B3}.Release|x86.ActiveCfg = Release|Win32
{AF9084C3-BF37-4A56-A851-89F3BAE731B3}.Release|x86.Build.0 = Release|Win32
{AF9084C3-BF37-4A56-A851-89F3BAE731B3}.Release|x86.Deploy.0 = Release|Win32
{B2F2A89C-55C9-41B1-A645-0948609BD8BE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
Copy link
Contributor

Choose a reason for hiding this comment

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

@hughbe I think mapping these to the correct target platform (.sln x86 = .csproj x86, etc) should fix the error "There was a mismatch between the processor architecture of the project being built "MSIL" and the processor architecture of the reference".

@dipeshmsft
Copy link
Member

/azp run

@azure-pipelines
Copy link

No commit pushedDate could be found for PR 138 in repo dotnet/wpf

@hughbe
Copy link
Contributor Author

hughbe commented Aug 21, 2023

Looks like things are finally green!!

@dipeshmsft
Copy link
Member

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@dipeshmsft dipeshmsft merged commit bde0f12 into dotnet:main Sep 6, 2023
8 checks passed
@hughbe hughbe deleted the attribute-tests branch September 6, 2023 05:19
@pchaurasia14
Copy link
Member

Thank you @hughbe! I apologize for the extended delay in merging this pull request.

@hughbe
Copy link
Contributor Author

hughbe commented Sep 6, 2023

Woot woot! Glad this is in

@ghost ghost locked as resolved and limited conversation to collaborators Oct 7, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Community Contribution A label for all community Contributions PR metadata: Label to tag PRs, to facilitate with triage
Projects
None yet
Development

Successfully merging this pull request may close these issues.