diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index accc46bb..4294bbc9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -9,36 +9,35 @@ on: jobs: - windows: - name: Windows - runs-on: windows-latest + build: + strategy: + fail-fast: false + matrix: + platform: + - name: Windows + os: windows-latest + - name: macOS + os: macos-14 + configuration: + - Debug + - Release + # Tries to AOT the test infrastructure assemblies which is not supported + exclude: + - platform: + name: macOS + configuration: Release + name: ${{ matrix.platform.name }} (${{ matrix.configuration }}) + runs-on: ${{ matrix.platform.os }} steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Setup Required Tools uses: ./.github/workflows/setup-tools - name: Build - run: dotnet build DeviceRunners.sln --configuration Release /bl:./artifacts/logs/msbuild-build.binlog + run: dotnet build DeviceRunners.sln --configuration ${{ matrix.configuration }} /bl:./artifacts/logs/msbuild-build.binlog - name: Upload Logs - uses: actions/upload-artifact@v1 + uses: actions/upload-artifact@v4 if: ${{ always() }} with: - name: Logs - Windows - path: ./artifacts/logs - - macos: - name: macOS - runs-on: macos-14 - steps: - - name: Checkout - uses: actions/checkout@v2 - - name: Setup Required Tools - uses: ./.github/workflows/setup-tools - - name: Build - run: dotnet build DeviceRunners.sln --configuration Debug /bl:./artifacts/logs/msbuild-build.binlog - - name: Upload Logs - uses: actions/upload-artifact@v1 - if: ${{ always() }} - with: - name: Logs - macOS + name: Logs - ${{ matrix.platform.name }} (${{ matrix.configuration }}) path: ./artifacts/logs diff --git a/.github/workflows/pack.yml b/.github/workflows/pack.yml index 4f8d408f..1f48c0bd 100644 --- a/.github/workflows/pack.yml +++ b/.github/workflows/pack.yml @@ -16,7 +16,7 @@ jobs: runs-on: windows-latest steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Setup Required Tools uses: ./.github/workflows/setup-tools - name: Package NuGets @@ -30,12 +30,12 @@ jobs: dotnet pack --output ./artifacts/nugets --configuration Release -p:PackageVersion=$VERSION /bl:./artifacts/logs/msbuild-pack.binlog - name: Upload NuGet Artifacts - uses: actions/upload-artifact@v1 + uses: actions/upload-artifact@v4 with: name: NuGet path: ./artifacts/nugets - name: Upload Logs - uses: actions/upload-artifact@v1 + uses: actions/upload-artifact@v4 if: ${{ always() }} with: name: Pack Logs - Windows @@ -55,7 +55,7 @@ jobs: with: name: NuGet - name: Setup .NET - uses: actions/setup-dotnet@v3 + uses: actions/setup-dotnet@v4 with: dotnet-version: '8.0.x' source-url: ${{ env.NUGET_URL }} diff --git a/.github/workflows/setup-tools/action.yml b/.github/workflows/setup-tools/action.yml index 032ff005..0e872661 100644 --- a/.github/workflows/setup-tools/action.yml +++ b/.github/workflows/setup-tools/action.yml @@ -11,9 +11,15 @@ runs: with: xcode-version: latest-stable - name: Setup .NET - uses: actions/setup-dotnet@v3 + uses: actions/setup-dotnet@v4 with: dotnet-version: 8.0.304 + - name: Show .NET Info + shell: pwsh + run: dotnet new globaljson --sdk-version 8.0.304 + - name: Show .NET Info + shell: pwsh + run: dotnet --info - name: Setup .NET MAUI if: runner.os == 'Linux' shell: pwsh diff --git a/.github/workflows/test-xharness-android.yml b/.github/workflows/test-xharness-android.yml index 0a559585..451ac26a 100644 --- a/.github/workflows/test-xharness-android.yml +++ b/.github/workflows/test-xharness-android.yml @@ -11,6 +11,7 @@ jobs: android: strategy: + fail-fast: false matrix: platform: - name: Linux @@ -19,7 +20,7 @@ jobs: - name: macOS os: macos-13 gpu: guest - name: Android (${{ matrix.platform.name}}) + name: Android (${{ matrix.platform.name }}) runs-on: ${{ matrix.platform.os }} env: TEST_TARGET_FRAMEWORK: net8.0-android @@ -29,7 +30,7 @@ jobs: TEST_EMULATOR_IMAGE: system-images;android-34;google_apis;x86_64 steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Setup Required Tools uses: ./.github/workflows/setup-tools - uses: actions/setup-java@v4 @@ -50,7 +51,7 @@ jobs: run: dotnet android avd start --name ${{ env.TEST_EMULATOR_NAME }} --gpu ${{ matrix.platform.gpu }} --wait-boot --no-window --no-snapshot --no-audio --no-boot-anim - name: Publish App run: | - dotnet publish sample/SampleMauiApp/SampleMauiApp.csproj \ + dotnet publish sample/test/DeviceTestingKitApp.DeviceTests/DeviceTestingKitApp.DeviceTests.csproj \ -f ${{ env.TEST_TARGET_FRAMEWORK }} \ -r ${{ env.TEST_RUNTIME_IDENTIFIER }} \ -c ${{ env.TEST_CONFIGURATION }} \ @@ -59,18 +60,23 @@ jobs: /bl:./artifacts/logs/msbuild-publish.binlog - name: Run Tests run: | - dotnet xharness android test \ - --timeout="00:05:00" \ - --launch-timeout=00:10:00 \ - --package-name com.companyname.samplemauiapp \ - --instrumentation devicerunners.xharness.maui.XHarnessInstrumentation \ - --app sample/SampleMauiApp/bin/${{ env.TEST_CONFIGURATION }}/${{ env.TEST_TARGET_FRAMEWORK }}/${{ env.TEST_RUNTIME_IDENTIFIER }}/publish/com.companyname.samplemauiapp-Signed.apk \ - --output-directory artifacts + for i in $(seq 1 3) + do + dotnet xharness android test \ + --timeout="00:05:00" \ + --launch-timeout=00:10:00 \ + --package-name com.companyname.devicetestingkitapp.devicetests \ + --instrumentation devicerunners.xharness.maui.XHarnessInstrumentation \ + --app sample/test/DeviceTestingKitApp.DeviceTests/bin/${{ env.TEST_CONFIGURATION }}/${{ env.TEST_TARGET_FRAMEWORK }}/${{ env.TEST_RUNTIME_IDENTIFIER }}/publish/com.companyname.devicetestingkitapp.devicetests-Signed.apk \ + --output-directory artifacts \ + && code=0 && break || code=$? && sleep 15 + done + exit $code - name: Shutdown the Emulator run: dotnet xharness android adb -- emu kill - name: Upload Artifacts - uses: actions/upload-artifact@v1 + uses: actions/upload-artifact@v4 if: ${{ always() }} with: - name: Test Results - Android (Linux) + name: Test Results - ${{ matrix.platform.name }} path: ./artifacts diff --git a/.github/workflows/test-xharness-ios.yml b/.github/workflows/test-xharness-ios.yml index 98305f81..38d7ae7c 100644 --- a/.github/workflows/test-xharness-ios.yml +++ b/.github/workflows/test-xharness-ios.yml @@ -18,12 +18,12 @@ jobs: TEST_CONFIGURATION: Debug steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Setup Required Tools uses: ./.github/workflows/setup-tools - name: Publish App run: | - dotnet build sample/SampleMauiApp/SampleMauiApp.csproj \ + dotnet build sample/test/DeviceTestingKitApp.DeviceTests/DeviceTestingKitApp.DeviceTests.csproj \ -f ${{ env.TEST_TARGET_FRAMEWORK }} \ -r ${{ env.TEST_RUNTIME_IDENTIFIER }} \ -c ${{ env.TEST_CONFIGURATION }} \ @@ -37,14 +37,14 @@ jobs: --target ios-simulator-64 \ --timeout="00:03:00" \ --launch-timeout=00:06:00 \ - --app sample/SampleMauiApp/bin/${{ env.TEST_CONFIGURATION }}/${{ env.TEST_TARGET_FRAMEWORK }}/${{ env.TEST_RUNTIME_IDENTIFIER }}/SampleMauiApp.app \ + --app sample/test/DeviceTestingKitApp.DeviceTests/bin/${{ env.TEST_CONFIGURATION }}/${{ env.TEST_TARGET_FRAMEWORK }}/${{ env.TEST_RUNTIME_IDENTIFIER }}/DeviceTestingKitApp.DeviceTests.app \ --output-directory artifacts \ && code=0 && break || code=$? && sleep 15 done exit $code - name: Upload Artifacts - uses: actions/upload-artifact@v1 + uses: actions/upload-artifact@v4 if: ${{ always() }} with: - name: Test Results - iOS + name: Test Results path: ./artifacts diff --git a/.github/workflows/test-xharness-maccatalyst.yml b/.github/workflows/test-xharness-maccatalyst.yml index d4fc233d..0600db21 100644 --- a/.github/workflows/test-xharness-maccatalyst.yml +++ b/.github/workflows/test-xharness-maccatalyst.yml @@ -18,12 +18,12 @@ jobs: TEST_CONFIGURATION: Debug steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Setup Required Tools uses: ./.github/workflows/setup-tools - name: Publish App run: | - dotnet build sample/SampleMauiApp/SampleMauiApp.csproj \ + dotnet build sample/test/DeviceTestingKitApp.DeviceTests/DeviceTestingKitApp.DeviceTests.csproj \ -f ${{ env.TEST_TARGET_FRAMEWORK }} \ -r ${{ env.TEST_RUNTIME_IDENTIFIER }} \ -c ${{ env.TEST_CONFIGURATION }} \ @@ -35,11 +35,11 @@ jobs: --target maccatalyst \ --timeout="00:02:00" \ --launch-timeout=00:06:00 \ - --app sample/SampleMauiApp/bin/${{ env.TEST_CONFIGURATION }}/${{ env.TEST_TARGET_FRAMEWORK }}/${{ env.TEST_RUNTIME_IDENTIFIER }}/SampleMauiApp.app \ + --app sample/test/DeviceTestingKitApp.DeviceTests/bin/${{ env.TEST_CONFIGURATION }}/${{ env.TEST_TARGET_FRAMEWORK }}/${{ env.TEST_RUNTIME_IDENTIFIER }}/DeviceTestingKitApp.DeviceTests.app \ --output-directory artifacts - name: Upload Artifacts - uses: actions/upload-artifact@v1 + uses: actions/upload-artifact@v4 if: ${{ always() }} with: - name: Test Results - Mac Catalyst + name: Test Results path: ./artifacts diff --git a/.github/workflows/test-xharness-windows.yml b/.github/workflows/test-xharness-windows.yml index 622d98a8..7385fd1f 100644 --- a/.github/workflows/test-xharness-windows.yml +++ b/.github/workflows/test-xharness-windows.yml @@ -18,13 +18,13 @@ jobs: TEST_CONFIGURATION: Release steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Setup Required Tools uses: ./.github/workflows/setup-tools - name: Publish App run: | - $fingerprint = ./scripts/New-Certificate.ps1 -Project sample/SampleMauiApp/SampleMauiApp.csproj - dotnet publish sample/SampleMauiApp/SampleMauiApp.csproj ` + $fingerprint = ./scripts/New-Certificate.ps1 -Project sample/test/DeviceTestingKitApp.DeviceTests/DeviceTestingKitApp.DeviceTests.csproj + dotnet publish sample/test/DeviceTestingKitApp.DeviceTests/DeviceTestingKitApp.DeviceTests.csproj ` -f ${{ env.TEST_TARGET_FRAMEWORK }} ` -c ${{ env.TEST_CONFIGURATION }} ` -p:TestingMode=XHarness ` @@ -35,15 +35,15 @@ jobs: ./scripts/Remove-Certificate.ps1 -CertificateFingerprint $fingerprint - name: Run Tests run: | - $msix = Get-ChildItem "sample/SampleMauiApp/bin/${{ env.TEST_CONFIGURATION }}/${{ env.TEST_TARGET_FRAMEWORK }}/${{ env.TEST_RUNTIME_IDENTIFIER }}/AppPackages/*_Test/*.msix" + $msix = Get-ChildItem "sample/test/DeviceTestingKitApp.DeviceTests/bin/${{ env.TEST_CONFIGURATION }}/${{ env.TEST_TARGET_FRAMEWORK }}/${{ env.TEST_RUNTIME_IDENTIFIER }}/AppPackages/*_Test/*.msix" ./scripts/Start-Tests.ps1 ` -App $msix ` -OutputDirectory artifacts ` -TestingMode XHarness shell: powershell - name: Upload Artifacts - uses: actions/upload-artifact@v1 + uses: actions/upload-artifact@v4 if: ${{ always() }} with: - name: Test Results - Windows + name: Test Results path: ./artifacts diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3d6f12ff..8c77a0ae 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -9,36 +9,27 @@ on: jobs: - windows: - name: Windows - runs-on: windows-latest + test: + strategy: + fail-fast: false + matrix: + platform: + - name: Windows + os: windows-latest + - name: macOS + os: macos-14 + name: ${{ matrix.platform.name }} + runs-on: ${{ matrix.platform.os }} steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Setup Required Tools uses: ./.github/workflows/setup-tools - name: Test run: dotnet test test/DeviceRunners.VisualRunners.Tests --configuration Release /bl:./artifacts/logs/msbuild-test.binlog - name: Upload Logs - uses: actions/upload-artifact@v1 + uses: actions/upload-artifact@v4 if: ${{ always() }} with: - name: Logs - Windows - path: ./artifacts/logs - - macos: - name: macOS - runs-on: macos-13 - steps: - - name: Checkout - uses: actions/checkout@v2 - - name: Setup Required Tools - uses: ./.github/workflows/setup-tools - - name: Test - run: dotnet test test/DeviceRunners.VisualRunners.Tests --configuration Release /bl:./artifacts/logs/msbuild-test.binlog - - name: Upload Logs - uses: actions/upload-artifact@v1 - if: ${{ always() }} - with: - name: Logs - macOS + name: Logs - ${{ matrix.platform.name }} path: ./artifacts/logs diff --git a/DeviceRunners.sln b/DeviceRunners.sln index 002c1e82..85701685 100644 --- a/DeviceRunners.sln +++ b/DeviceRunners.sln @@ -9,11 +9,11 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{DBF1C119-C96 EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{5073EAFD-FF7B-4C4E-84D2-3AA38A91DE73}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SampleMauiApp", "sample\SampleMauiApp\SampleMauiApp.csproj", "{254F1542-8CBD-4FF3-81FB-8C311D53DE70}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DeviceTestingKitApp.DeviceTests", "sample\test\DeviceTestingKitApp.DeviceTests\DeviceTestingKitApp.DeviceTests.csproj", "{254F1542-8CBD-4FF3-81FB-8C311D53DE70}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SampleNUnitTestProject", "sample\SampleNUnitTestProject\SampleNUnitTestProject.csproj", "{34760EB3-3B55-49A6-8632-ABC6FA5E6786}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DeviceTestingKitApp.Library.NUnitTests", "sample\test\DeviceTestingKitApp.Library.NUnitTests\DeviceTestingKitApp.Library.NUnitTests.csproj", "{34760EB3-3B55-49A6-8632-ABC6FA5E6786}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SampleXunitTestProject", "sample\SampleXunitTestProject\SampleXunitTestProject.csproj", "{52AB8946-1EDE-4BF2-B397-4422862AB2E1}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DeviceTestingKitApp.MauiLibrary.XunitTests", "sample\test\DeviceTestingKitApp.MauiLibrary.XunitTests\DeviceTestingKitApp.MauiLibrary.XunitTests.csproj", "{52AB8946-1EDE-4BF2-B397-4422862AB2E1}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DeviceRunners.Core", "src\DeviceRunners.Core\DeviceRunners.Core.csproj", "{F71BD057-A790-4676-A19D-9AFBB1E8A052}" EndProject @@ -41,6 +41,16 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DeviceRunners.UITesting", " EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DeviceRunners.UITesting.Maui", "src\DeviceRunners.UITesting.Maui\DeviceRunners.UITesting.Maui.csproj", "{1D67F157-3201-49D4-AA58-40716D7D00EC}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DeviceTestingKitApp", "sample\src\DeviceTestingKitApp\DeviceTestingKitApp.csproj", "{D9094DA2-3D7F-4613-9569-CCF71629AA1D}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DeviceTestingKitApp.MauiLibrary", "sample\src\DeviceTestingKitApp.MauiLibrary\DeviceTestingKitApp.MauiLibrary.csproj", "{DBAB5271-347E-4C0E-B326-045723583A07}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DeviceTestingKitApp.Library", "sample\src\DeviceTestingKitApp.Library\DeviceTestingKitApp.Library.csproj", "{D4350725-949D-4F7B-ABED-E4F493952D14}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{7FD9E644-B760-47D7-A4FC-61199AFE9D62}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{EE37724C-5FEF-46BB-AD80-CD002CC7FF54}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -113,14 +123,28 @@ Global {1D67F157-3201-49D4-AA58-40716D7D00EC}.Debug|Any CPU.Build.0 = Debug|Any CPU {1D67F157-3201-49D4-AA58-40716D7D00EC}.Release|Any CPU.ActiveCfg = Release|Any CPU {1D67F157-3201-49D4-AA58-40716D7D00EC}.Release|Any CPU.Build.0 = Release|Any CPU + {D9094DA2-3D7F-4613-9569-CCF71629AA1D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D9094DA2-3D7F-4613-9569-CCF71629AA1D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D9094DA2-3D7F-4613-9569-CCF71629AA1D}.Debug|Any CPU.Deploy.0 = Debug|Any CPU + {D9094DA2-3D7F-4613-9569-CCF71629AA1D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D9094DA2-3D7F-4613-9569-CCF71629AA1D}.Release|Any CPU.Build.0 = Release|Any CPU + {D9094DA2-3D7F-4613-9569-CCF71629AA1D}.Release|Any CPU.Deploy.0 = Release|Any CPU + {DBAB5271-347E-4C0E-B326-045723583A07}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DBAB5271-347E-4C0E-B326-045723583A07}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DBAB5271-347E-4C0E-B326-045723583A07}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DBAB5271-347E-4C0E-B326-045723583A07}.Release|Any CPU.Build.0 = Release|Any CPU + {D4350725-949D-4F7B-ABED-E4F493952D14}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D4350725-949D-4F7B-ABED-E4F493952D14}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D4350725-949D-4F7B-ABED-E4F493952D14}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D4350725-949D-4F7B-ABED-E4F493952D14}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution - {254F1542-8CBD-4FF3-81FB-8C311D53DE70} = {46348E44-C1A8-4923-B3E9-7B9217BA5792} - {34760EB3-3B55-49A6-8632-ABC6FA5E6786} = {46348E44-C1A8-4923-B3E9-7B9217BA5792} - {52AB8946-1EDE-4BF2-B397-4422862AB2E1} = {46348E44-C1A8-4923-B3E9-7B9217BA5792} + {254F1542-8CBD-4FF3-81FB-8C311D53DE70} = {EE37724C-5FEF-46BB-AD80-CD002CC7FF54} + {34760EB3-3B55-49A6-8632-ABC6FA5E6786} = {EE37724C-5FEF-46BB-AD80-CD002CC7FF54} + {52AB8946-1EDE-4BF2-B397-4422862AB2E1} = {EE37724C-5FEF-46BB-AD80-CD002CC7FF54} {F71BD057-A790-4676-A19D-9AFBB1E8A052} = {DBF1C119-C96C-4DD3-810B-52451603475C} {9AFBB1E8-A790-4676-A19D-F71BD05A052E} = {DBF1C119-C96C-4DD3-810B-52451603475C} {709B3B0B-46E7-4EBE-B8CD-1E4BF6D4ADE1} = {DBF1C119-C96C-4DD3-810B-52451603475C} @@ -134,6 +158,11 @@ Global {27DD8F93-86FA-4AA8-AEB0-00F6335A4619} = {5073EAFD-FF7B-4C4E-84D2-3AA38A91DE73} {7040FAB6-5FD1-4D37-9DEB-1529802E2D34} = {DBF1C119-C96C-4DD3-810B-52451603475C} {1D67F157-3201-49D4-AA58-40716D7D00EC} = {DBF1C119-C96C-4DD3-810B-52451603475C} + {D9094DA2-3D7F-4613-9569-CCF71629AA1D} = {7FD9E644-B760-47D7-A4FC-61199AFE9D62} + {DBAB5271-347E-4C0E-B326-045723583A07} = {7FD9E644-B760-47D7-A4FC-61199AFE9D62} + {D4350725-949D-4F7B-ABED-E4F493952D14} = {7FD9E644-B760-47D7-A4FC-61199AFE9D62} + {7FD9E644-B760-47D7-A4FC-61199AFE9D62} = {46348E44-C1A8-4923-B3E9-7B9217BA5792} + {EE37724C-5FEF-46BB-AD80-CD002CC7FF54} = {46348E44-C1A8-4923-B3E9-7B9217BA5792} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {2DABD41C-B083-429E-AE1E-971CFF8DC199} diff --git a/README.md b/README.md index 9bc9c015..826d2154 100644 --- a/README.md +++ b/README.md @@ -54,5 +54,5 @@ This is repository contains revised code from a few places: This code was migrated to use .NET MAUI. - https://github.com/nunit/nunit.xamarin This code was migrated to use .NET MAUI and then features were added to support running individual tests. - - https://github.com/dotnet/maui + - https://github.com/dotnet/maui This was the home for a short while during the migration. diff --git a/sample/Directory.Build.props b/sample/Directory.Build.props new file mode 100644 index 00000000..d819ef35 --- /dev/null +++ b/sample/Directory.Build.props @@ -0,0 +1,9 @@ + + + + + + false + + + \ No newline at end of file diff --git a/sample/README.md b/sample/README.md new file mode 100644 index 00000000..b9d6e835 --- /dev/null +++ b/sample/README.md @@ -0,0 +1,43 @@ +# DeviceTestingKitApp Sample App + +This folder contains a convoluted sample app with all the different ways to run and test it. + +In a typical scenario, you would not actually do all of this, but rather pick a few +mechanisms depending on the app type and tests types. + +## Projects + +### The `src` Folder + +This folder represents a ".NET MAUI app" in a somewhat convoluted format to demonstrate +the different mechanisms available for testing. + +This folder has 3 sub-folders with different types of projects: + +* `DeviceTestingKitApp` + This is the main app that is published to the app store. It is very simple and just + contains a single page with some text, and image and a counter button. +* `DeviceTestingKitApp.MauiLibrary` + This is a .NET MAUI class library that use a few features of .NET MAUI in a class + library (instead of an app) so that a normal unit test can run against these. +* `DeviceTestingKitApp.Library` + This is a normal class library that has a few view models and services. + +### The `test` Folder + +This folder represents the possible tests you may have for your app: + +* `DeviceTestingKitApp.DeviceTests` + This is a device tests app to run all the tests on an actual device instead of just + in the IDE on the host machine. The host machine will not be the most accurate test + of the features in the app because many code paths may require or expect to be + running in an app environment. + This project also contains several sample tests to demosnstrate how to write tests that + are designed to run on a device and expect device features. +* `DeviceTestingKitApp.MauiLibrary.XunitTests` + This is a set of unit tests (that can run on both the host machine and the device) that + test the functionality of the .NET MAUI app components. In this example, it is testing + the various XAML views and value converters that only exist in the context of .NET MAUI. +* `DeviceTestingKitApp.Library.NUnitTests` + This is a set of unit tests that test the functionality of view models and other + framework-agnostic code. diff --git a/sample/src/DeviceTestingKitApp.Library/DeviceTestingKitApp.Library.csproj b/sample/src/DeviceTestingKitApp.Library/DeviceTestingKitApp.Library.csproj new file mode 100644 index 00000000..66aee79e --- /dev/null +++ b/sample/src/DeviceTestingKitApp.Library/DeviceTestingKitApp.Library.csproj @@ -0,0 +1,14 @@ + + + + net8.0 + enable + enable + DeviceTestingKitApp + + + + + + + diff --git a/sample/src/DeviceTestingKitApp.Library/Features/ISemanticAnnouncer.cs b/sample/src/DeviceTestingKitApp.Library/Features/ISemanticAnnouncer.cs new file mode 100644 index 00000000..4d6235b2 --- /dev/null +++ b/sample/src/DeviceTestingKitApp.Library/Features/ISemanticAnnouncer.cs @@ -0,0 +1,6 @@ +namespace DeviceTestingKitApp.Features; + +public interface ISemanticAnnouncer +{ + void Announce(string message); +} diff --git a/sample/src/DeviceTestingKitApp.Library/ViewModels/BaseViewModel.cs b/sample/src/DeviceTestingKitApp.Library/ViewModels/BaseViewModel.cs new file mode 100644 index 00000000..d6e927cf --- /dev/null +++ b/sample/src/DeviceTestingKitApp.Library/ViewModels/BaseViewModel.cs @@ -0,0 +1,7 @@ +using CommunityToolkit.Mvvm.ComponentModel; + +namespace DeviceTestingKitApp.ViewModels; + +public class BaseViewModel : ObservableObject +{ +} diff --git a/sample/src/DeviceTestingKitApp.Library/ViewModels/CounterViewModel.cs b/sample/src/DeviceTestingKitApp.Library/ViewModels/CounterViewModel.cs new file mode 100644 index 00000000..f2051360 --- /dev/null +++ b/sample/src/DeviceTestingKitApp.Library/ViewModels/CounterViewModel.cs @@ -0,0 +1,16 @@ +using CommunityToolkit.Mvvm.ComponentModel; +using CommunityToolkit.Mvvm.Input; + +namespace DeviceTestingKitApp.ViewModels; + +public partial class CounterViewModel : BaseViewModel +{ + [ObservableProperty] + private int _count; + + [RelayCommand] + private void Increment() + { + Count++; + } +} diff --git a/sample/src/DeviceTestingKitApp.Library/ViewModels/MainViewModel.cs b/sample/src/DeviceTestingKitApp.Library/ViewModels/MainViewModel.cs new file mode 100644 index 00000000..9fe487f2 --- /dev/null +++ b/sample/src/DeviceTestingKitApp.Library/ViewModels/MainViewModel.cs @@ -0,0 +1,11 @@ +namespace DeviceTestingKitApp.ViewModels; + +public partial class MainViewModel : BaseViewModel +{ + public MainViewModel(CounterViewModel counter) + { + Counter = counter; + } + + public CounterViewModel Counter { get; } +} diff --git a/sample/src/DeviceTestingKitApp.MauiLibrary/Controls/CounterView.xaml b/sample/src/DeviceTestingKitApp.MauiLibrary/Controls/CounterView.xaml new file mode 100644 index 00000000..10fb32f5 --- /dev/null +++ b/sample/src/DeviceTestingKitApp.MauiLibrary/Controls/CounterView.xaml @@ -0,0 +1,21 @@ + + + + + + + + + +