<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to write unit tests with Maps SDK and MAUI in .NET Maps SDK Questions</title>
    <link>https://community.esri.com/t5/net-maps-sdk-questions/how-to-write-unit-tests-with-maps-sdk-and-maui/m-p/1342299#M12234</link>
    <description>&lt;P&gt;&lt;SPAN&gt;&amp;gt; With Xamarin Forms and ArcGIS Runtime 100.x we were able to run the tests using .net 6 using the test explorer.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Xamarin.Forms had the same limitation. For .NET 6 it is similar that you need to target net6-windows even with 100.15. That hasn't changed with 200.x.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;We've frequently asked Microsoft to improve their test framework to better support both WinUI, iOS and Android, because we realize it is limited, and we don't want to maintain our custom test runners any more than you do.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 26 Oct 2023 20:01:33 GMT</pubDate>
    <dc:creator>dotMorten_esri</dc:creator>
    <dc:date>2023-10-26T20:01:33Z</dc:date>
    <item>
      <title>How to write unit tests with Maps SDK and MAUI</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/how-to-write-unit-tests-with-maps-sdk-and-maui/m-p/1340567#M12202</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I've tried several methods of being able to write unit tests with MAUI and the Maps SDK but none have worked. I tried the approach described here:&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.youtube.com/watch?v=C9vIDLQwc7M" target="_blank" rel="noopener"&gt;https://www.youtube.com/watch?v=C9vIDLQwc7M&lt;/A&gt;&lt;/P&gt;&lt;P&gt;and here:&amp;nbsp;&lt;A href="https://cedricgabrang.medium.com/adding-xunit-test-to-your-net-maui-project-ee36c00a8542" target="_blank" rel="noopener"&gt;https://cedricgabrang.medium.com/adding-xunit-test-to-your-net-maui-project-ee36c00a8542&lt;/A&gt;&lt;/P&gt;&lt;P&gt;This is with a brand new MSTest project template from VS. csproj looks like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;Project Sdk="Microsoft.NET.Sdk"&amp;gt;

&amp;lt;PropertyGroup&amp;gt;
&amp;lt;TargetFramework&amp;gt;net7.0&amp;lt;/TargetFramework&amp;gt;
&amp;lt;ImplicitUsings&amp;gt;enable&amp;lt;/ImplicitUsings&amp;gt;
&amp;lt;Nullable&amp;gt;enable&amp;lt;/Nullable&amp;gt;

&amp;lt;IsPackable&amp;gt;false&amp;lt;/IsPackable&amp;gt;
&amp;lt;IsTestProject&amp;gt;true&amp;lt;/IsTestProject&amp;gt;
&amp;lt;/PropertyGroup&amp;gt;

&amp;lt;ItemGroup&amp;gt;
&amp;lt;PackageReference Include="Esri.ArcGISRuntime" Version="200.2.0" /&amp;gt;
&amp;lt;PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.1" /&amp;gt;
&amp;lt;PackageReference Include="MSTest.TestAdapter" Version="2.2.10" /&amp;gt;
&amp;lt;PackageReference Include="MSTest.TestFramework" Version="2.2.10" /&amp;gt;
&amp;lt;PackageReference Include="coverlet.collector" Version="3.2.0" /&amp;gt;
&amp;lt;/ItemGroup&amp;gt;

&amp;lt;/Project&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This works fine without Maps SDK, but as soon as I add the Esri.ArcGISRuntime nuget package reference, I get this:&lt;/P&gt;&lt;P&gt;Severity Code Description Project File Line Suppression State&lt;BR /&gt;Error The 'Esri.ArcGISRuntime' nuget package cannot be used to target 'net7.0' for output type 'Exe'. Only platform-agnostic class libraries or Windows, iOS and Android platforms are supported. TestProject1 C:\Users\JSIEMENS\.nuget\packages\esri.arcgisruntime\200.2.0\buildTransitive\net6.0\Esri.ArcGISRuntime.targets 5&lt;/P&gt;&lt;P&gt;So then I saw a suggestion to set the TargetFramework to "net7.0-windows10.0.19041.0", so I try that, and it works fine without Maui, but once I add &lt;SPAN&gt;&amp;lt;UseMaui&amp;gt;true&amp;lt;/UseMaui&amp;gt;, then I get:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Architecture: x64&lt;BR /&gt;Framework: 'Microsoft.Maui.Core', version '**FromWorkload**' (x64)&lt;BR /&gt;.NET location: C:\Program Files\dotnet\&lt;BR /&gt;No frameworks were found.&lt;BR /&gt;Learn about framework resolution:&lt;BR /&gt;&lt;A href="https://aka.ms/dotnet/app-launch-failed" target="_blank" rel="noopener"&gt;https://aka.ms/dotnet/app-launch-failed&lt;/A&gt;&lt;BR /&gt;To install missing framework, download:&lt;BR /&gt;&lt;A href="https://aka.ms/dotnet-core-applaunch?framework=Microsoft.Maui.Core&amp;amp;framework_version=**FromWorkload**&amp;amp;arch=x64&amp;amp;rid=win10-x64" target="_blank" rel="noopener"&gt;https://aka.ms/dotnet-core-applaunch?framework=Microsoft.Maui.Core&amp;amp;framework_version=**FromWorkload**&amp;amp;arch=x64&amp;amp;rid=win10-x64&lt;/A&gt;&lt;BR /&gt;. Please check the diagnostic logs for more information.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;It feels the same as this issue:&lt;/P&gt;&lt;P&gt;&lt;A href="https://github.com/dotnet/maui/issues/17914" target="_blank" rel="noopener"&gt;https://github.com/dotnet/maui/issues/17914&lt;/A&gt;&lt;/P&gt;&lt;P&gt;And:&amp;nbsp;&lt;A href="https://github.com/dotnet/maui/issues/11575" target="_blank" rel="noopener"&gt;https://github.com/dotnet/maui/issues/11575&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Here's the csproj again.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;Project Sdk="Microsoft.NET.Sdk"&amp;gt;

  &amp;lt;PropertyGroup&amp;gt;
    &amp;lt;TargetFramework&amp;gt;net7.0-windows10.0.19041.0&amp;lt;/TargetFramework&amp;gt;
    &amp;lt;ImplicitUsings&amp;gt;enable&amp;lt;/ImplicitUsings&amp;gt;
    &amp;lt;Nullable&amp;gt;enable&amp;lt;/Nullable&amp;gt;
	&amp;lt;UseMaui&amp;gt;true&amp;lt;/UseMaui&amp;gt;

    &amp;lt;IsPackable&amp;gt;false&amp;lt;/IsPackable&amp;gt;
    &amp;lt;IsTestProject&amp;gt;true&amp;lt;/IsTestProject&amp;gt;
  &amp;lt;/PropertyGroup&amp;gt;

  &amp;lt;ItemGroup&amp;gt;
    &amp;lt;PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.1" /&amp;gt;
    &amp;lt;PackageReference Include="MSTest.TestAdapter" Version="2.2.10" /&amp;gt;
    &amp;lt;PackageReference Include="MSTest.TestFramework" Version="2.2.10" /&amp;gt;
    &amp;lt;PackageReference Include="coverlet.collector" Version="3.2.0" /&amp;gt;
  &amp;lt;/ItemGroup&amp;gt;

&amp;lt;/Project&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So at this point in time, it feels like there is no way to run unit tests against a project that uses both MAUI and the ArcGIS Maps SDK. What am I missing? Is there a way to get tests to work?&lt;/P&gt;&lt;P&gt;Formerly with Xamarin Forms and UWP, there was a UWP test project template (which was horrifically slow to run tests with), but that doesn't seem to be a thing anymore with WinUI3.&lt;/P&gt;</description>
      <pubDate>Mon, 23 Oct 2023 16:58:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/how-to-write-unit-tests-with-maps-sdk-and-maui/m-p/1340567#M12202</guid>
      <dc:creator>jsiemensLatitudegeo</dc:creator>
      <dc:date>2023-10-23T16:58:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to write unit tests with Maps SDK and MAUI</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/how-to-write-unit-tests-with-maps-sdk-and-maui/m-p/1340611#M12204</link>
      <description>&lt;P&gt;&lt;SPAN&gt;&amp;gt; So at this point in time, it feels like there is no way to run unit tests against a project that uses both MAUI and the ArcGIS Maps SDK.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The Maps SDK only ships runtimes for Windows, iOS, Catalyst and Android. You _must_ run the unit tests in the context of these platforms, which means executing the tests in the context of an application (similar to how UWP did, but you can probably get your Windows build run un-packaged to run from commandline - see doc on running unpackaged WinUI apps). When you add the UseMaui bit, I believe it defaults to running the apps as packaged - the command line for executing tests in packaged Windows apps is similar to how you'd run UWP unit tests.&lt;BR /&gt;&lt;BR /&gt;We run unit tests daily with maui, and we basically launch an runner-app that runs the tests and reports the results back. This is mostly a home-grown system, since Microsoft still hasn't provided a good OOTB solution for executing unit tests on devices and inside WinUI packaged apps.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 23 Oct 2023 18:21:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/how-to-write-unit-tests-with-maps-sdk-and-maui/m-p/1340611#M12204</guid>
      <dc:creator>dotMorten_esri</dc:creator>
      <dc:date>2023-10-23T18:21:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to write unit tests with Maps SDK and MAUI</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/how-to-write-unit-tests-with-maps-sdk-and-maui/m-p/1342293#M12233</link>
      <description>&lt;P&gt;This puts us in a very difficult position. I'm not really sure how to go about creating a runner to the run the tests. I see there are some approaches that use a 'visual runner' that's effectively just an app that runs the tests. But I'm not sure how I can integrate that with the command line to run on a CI build server, and I fear the development workflow for running those tests would be horrifically slow and cumbersome.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;With Xamarin Forms and ArcGIS Runtime 100.x we were able to run the tests using .net 6 using the test explorer and easily integrate into the build pipeline using dotnet test.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;At this point, I'm investigating the idea of splitting up our code base to factor out the Esri bits and the UI bits so that I can create a net7 build output to unit test everything that isn't Esri, and a separate project that has all the Esri stuff and no UI so I can unit test that with &lt;SPAN&gt;net7.0-windows10.0.19041.0&lt;/SPAN&gt;.&lt;/P&gt;</description>
      <pubDate>Thu, 26 Oct 2023 19:56:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/how-to-write-unit-tests-with-maps-sdk-and-maui/m-p/1342293#M12233</guid>
      <dc:creator>jsiemensLatitudegeo</dc:creator>
      <dc:date>2023-10-26T19:56:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to write unit tests with Maps SDK and MAUI</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/how-to-write-unit-tests-with-maps-sdk-and-maui/m-p/1342299#M12234</link>
      <description>&lt;P&gt;&lt;SPAN&gt;&amp;gt; With Xamarin Forms and ArcGIS Runtime 100.x we were able to run the tests using .net 6 using the test explorer.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Xamarin.Forms had the same limitation. For .NET 6 it is similar that you need to target net6-windows even with 100.15. That hasn't changed with 200.x.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;We've frequently asked Microsoft to improve their test framework to better support both WinUI, iOS and Android, because we realize it is limited, and we don't want to maintain our custom test runners any more than you do.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Oct 2023 20:01:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/how-to-write-unit-tests-with-maps-sdk-and-maui/m-p/1342299#M12234</guid>
      <dc:creator>dotMorten_esri</dc:creator>
      <dc:date>2023-10-26T20:01:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to write unit tests with Maps SDK and MAUI</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/how-to-write-unit-tests-with-maps-sdk-and-maui/m-p/1342312#M12235</link>
      <description>&lt;P&gt;With Runtime 100.x and .net 6, we could add the reference to the ArcGIS Runtime, but if we loaded a class that referenced any of the Runtime 100.x UI (eg. MapView) then it would throw an exception, so we developed an interface around MapView, and used the interface instead of MapView. We could run the real Esri MapView at application runtime and a test implementation of MapView during unit tests.&lt;/P&gt;&lt;P&gt;With 200.x, we can't even install the package.&lt;/P&gt;</description>
      <pubDate>Thu, 26 Oct 2023 20:06:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/how-to-write-unit-tests-with-maps-sdk-and-maui/m-p/1342312#M12235</guid>
      <dc:creator>jsiemensLatitudegeo</dc:creator>
      <dc:date>2023-10-26T20:06:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to write unit tests with Maps SDK and MAUI</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/how-to-write-unit-tests-with-maps-sdk-and-maui/m-p/1342330#M12236</link>
      <description>&lt;P&gt;For example, previously I could do this inside a .net6 unit test app and it worked.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;    [TestClass]
    public class UnitTest1
    {
        [TestMethod]
        public async Task TestMethod1()
        {
            var portal = await ArcGISPortal.CreateAsync();
        }
    }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now, there's a build target that prevents the app from building. If I remove that check in the build target, I get:&lt;/P&gt;&lt;P&gt;Error: System.BadImageFormatException: Could not load file or assembly 'Esri.ArcGISRuntime, Version=200.2.0.0, Culture=neutral, PublicKeyToken=8fc3cc631e44ad86'. Reference assemblies cannot be loaded for execution. (0x80131058)&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Oct 2023 20:36:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/how-to-write-unit-tests-with-maps-sdk-and-maui/m-p/1342330#M12236</guid>
      <dc:creator>jsiemensLatitudegeo</dc:creator>
      <dc:date>2023-10-26T20:36:26Z</dc:date>
    </item>
  </channel>
</rss>

