Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<NUnitVersion Condition="'$(NUnitVersion)' == ''">4.1.0</NUnitVersion>
<NUnit3TestAdapterVersion Condition="'$(NUnit3TestAdapterVersion)' == ''">4.5.0</NUnit3TestAdapterVersion>
<FluentAssertionsVersion Condition="'$(FluentAssertionsVersion)' == ''">6.12.0</FluentAssertionsVersion>
<ShouldlyVersion Condition="'$(ShouldlyVersion)' == ''">4.3.0</ShouldlyVersion>
<CoverletCollectorVersion Condition="'$(CoverletCollectorVersion)' == ''">6.0.2</CoverletCollectorVersion>
<NewtonsoftJsonVersion Condition="'$(NewtonsoftJsonVersion)' == ''">13.0.3</NewtonsoftJsonVersion>
<XamarinUITestVersion Condition="'$(XamarinUITestVersion)' == ''">4.3.4</XamarinUITestVersion>
Expand Down
1 change: 1 addition & 0 deletions src/Uno.Templates/Uno.Templates.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
<ReplaceFileText Filename="%(_VersionableFile.Identity)" MatchExpression="$NUnit$" ReplacementText="$(NUnitVersion)" />
<ReplaceFileText Filename="%(_VersionableFile.Identity)" MatchExpression="$NUnit3TestAdapter$" ReplacementText="$(NUnit3TestAdapterVersion)" />
<ReplaceFileText Filename="%(_VersionableFile.Identity)" MatchExpression="$FluentAssertions$" ReplacementText="$(FluentAssertionsVersion)" />
<ReplaceFileText Filename="%(_VersionableFile.Identity)" MatchExpression="$Shouldly$" ReplacementText="$(ShouldlyVersion)" />
<ReplaceFileText Filename="%(_VersionableFile.Identity)" MatchExpression="$CoverletCollector$" ReplacementText="$(CoverletCollectorVersion)" />
<ReplaceFileText Filename="%(_VersionableFile.Identity)" MatchExpression="$NewtonsoftJson$" ReplacementText="$(NewtonsoftJsonVersion)" />
<ReplaceFileText Filename="%(_VersionableFile.Identity)" MatchExpression="$XamarinUITest$" ReplacementText="$(XamarinUITestVersion)" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
"server": "false",
"skipRestore": "true",
"tests": "none",
"assertionLibrary": "none",
"tfm": "net9.0",
"toolkit": "false",
"vscode": "true",
Expand All @@ -112,7 +113,7 @@
"renderer": "skia"
},
"Features": [
".NET 8",
".NET 9",
"XAML"
]
},
Expand All @@ -139,6 +140,7 @@
"server": "false",
"skipRestore": "true",
"tests": "none",
"assertionLibrary": "none",
"tfm": "net9.0",
"toolkit": "true",
"vscode": "true",
Expand All @@ -154,7 +156,7 @@
"renderer": "skia"
},
"Features": [
".NET 8",
".NET 9",
"XAML",
"MVUX",
"Material",
Expand Down Expand Up @@ -293,6 +295,13 @@
"SectionType": "MultiSelect",
"SymbolId": "tests",
"Choices": [ "unit", "ui" ]
},
{
"Title": "Assertion Library",
"SectionType": "SingleSelect",
"SymbolId": "assertionLibrary",
"Choices": [ "none", "Shouldly", "FluentAssertions" ],
"NestedIn": "tests"
}
],
"Theme": [
Expand Down Expand Up @@ -653,6 +662,31 @@

"Icon": "/Assets/Test.UnitTest.svg"
},
"tests.ui.assertion": {
"NoValue": "none"
},
"tests.ui.assertion.shouldly": {
// "Icon": "/Assets/Test.UiTest.Shouldly.svg" TODO: Add icon
"Sequence": 1,
"Tag":{
"Requires": {
"tests": {
"RequiredValues": [ "!none" ],
"MoreInformation": "Test selection is required to use Shouldly Assertion library"
}
}
}
},
"tests.ui.assertion.fluentAssertions": {
// "Icon": "/Assets/Test.UiTest.FluentAssertions.svg" TODO: Add icon
"Sequence": 2,
"Requires": {
"tests": {
"RequiredValues": [ "!none" ],
"MoreInformation": "Test selection is required to use Fluent Assertions library"
}
}
},
"tfm.net6.0": {
"Sequence": 1,
"Icon": "/Assets/Framework.NET6.svg"
Expand Down Expand Up @@ -756,6 +790,7 @@
"appTheme",
"platforms",
"tests",
"assertionLibrary",
"server",
"dependencyInjection",
"configuration",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@
"longName": "tests",
"shortName": "tests"
},
"assertionLibrary": {
"longName": "assertion-library",
"shortName": "assertion"
},
"toolkit": {
"longName": "toolkit",
"shortName": "toolkit"
Expand Down
41 changes: 41 additions & 0 deletions src/Uno.Templates/content/unoapp/.template.config/template.json
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,39 @@
}
]
},
"assertionLibrary": {
"displayName": "Assertion Library",
"type": "parameter",
"datatype": "choice",
"defaultValue": "none",
"allowMultipleValues": false,
"description": "Choose the assertion library for tests",
"enableQuotelessLiterals": true,
"isEnabled": "tests != none",
"onlyIf": [
{
"symbol": "tests",
"value":"unit|ui"
}
],
"choices": [
{
"choice": "none",
"displayName": "No Assertion Library",
"description": "Do not use any specific assertion library and only use the built-in assertions provided by the test framework"
},
{
"choice": "Shouldly",
"displayName": "Shouldly",
"description": "Use Shouldly for assertions in tests"
},
{
"choice": "FluentAssertions",
"displayName": "Fluent Assertions",
"description": "Use Fluent Assertions for assertions in tests"
}
]
},
"AllowPrereleaseNetSdk": {
"type": "generated",
"generator": "switch",
Expand Down Expand Up @@ -1190,6 +1223,14 @@
"pattern": ".*ui.*"
}
},
"useFluentAssertions": {
"type": "computed",
"value": "(assertionLibrary == FluentAssertions)"
},
"useShouldly": {
"type": "computed",
"value": "(assertionLibrary == Shouldly)"
},
"useServer": {
"type": "computed",
"datatype": "bool",
Expand Down
5 changes: 5 additions & 0 deletions src/Uno.Templates/content/unoapp/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@
<ItemGroup>
<!--#if (useTestSolutionFolder)-->
<PackageVersion Include="coverlet.collector" Version="$CoverletCollector$" />
<!--#if (useFluentAssertions)-->
<PackageVersion Include="FluentAssertions" Version="$FluentAssertions$" />
<!--#endif-->
<!--#if (useShouldly)-->
<PackageVersion Include="Shouldly" Version="$ShouldlyVersion$" />
<!--#endif-->
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="$MicrosoftTestSdk$" />
<PackageVersion Include="NUnit" Version="$NUnit$" />
<PackageVersion Include="NUnit3TestAdapter" Version="$NUnit3TestAdapter$" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,16 @@ public void Setup()
public void AppInfoCreation()
{
var appInfo = new AppConfig { Environment = "Test" };

#if(useFluentAssertions)
appInfo.Should().NotBeNull();
appInfo.Environment.Should().Be("Test");
#endif
#if(useShouldly)
appInfo.ShouldNotBeNull();
appInfo.Environment.ShouldBe("Test");
#else
Assert.That(appInfo,Is.Not.Null);
Assert.That(appInfo.Environment, Is.EqualTo("Test"));
#endif
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
//+:cnd:noEmit
global using FluentAssertions;
//-:cnd:noEmit
#if useBusinessModelsNamespace
global using MyExtensionsApp._1.Models;
#endif
#if(useFluentAssertions)
global using FluentAssertions;
#endif
#if(useShouldly)
global using Shouldly;
#endif
global using NUnit.Framework;
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@
</PropertyGroup>

<ItemGroup>
<!--#if (useFluentAssertions)-->
<PackageReference Include="FluentAssertions" />
<!--#endif-->
<!--#if (useShouldly)-->
<PackageReference Include="Shouldly" />
<!--#endif-->
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="NUnit" />
<PackageReference Include="NUnit3TestAdapter" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@
</PropertyGroup>

<ItemGroup>
<!--#if (useFluentAssertions)-->
<PackageReference Include="FluentAssertions" />
<!--#endif-->
<!--#if(useShouldly)-->
<PackageReference Include="Shouldly" />
<!--#endif-->
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="Newtonsoft.Json" />
<PackageReference Include="NUnit" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
},
"unoUITestHelpersVersion": {
"isHidden": true
},
"assertionLibrary": {
"longName": "assertionLibrary",
"shortName": "assertion"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,41 @@
"description": "Target .NET 9.0 (Standard Term Support)"
}
]
},
"assertionLibrary": {
"displayName": "Assertion Library",
"type": "parameter",
"datatype": "choice",
"defaultValue": "none",
"enableQuotelessLiterals": true,
"allowMultipleValues": false,
"isEnabled": "tests != none",
"description": "Choose the assertion library for tests",
"choices": [
{
"choice": "none",
"displayName": "No Assertion Library",
"description": "Do not use any specific assertion library and only use the built-in assertions provided by the test framework"
},
{
"choice": "Shouldly",
"displayName": "Shouldly",
"description": "Use Shouldly for assertions in tests"
},
{
"choice": "FluentAssertions",
"displayName": "Fluent Assertions",
"description": "Use Fluent Assertions for assertions in tests"
}
]
},
"useFluentAssertions": {
"type": "computed",
"value": "(assertionLibrary == FluentAssertions)"
},
"useShouldly": {
"type": "computed",
"value": "(assertionLibrary == Shouldly)"
}
},
"primaryOutputs": [
Expand Down
18 changes: 6 additions & 12 deletions src/Uno.Templates/content/unolib-uitest/Constants.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
//-:cnd:noEmit
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Uno.UITest.Helpers.Queries;

namespace UnoUITestsLibrary;

public class Constants
{
public readonly static string WebAssemblyDefaultUri = "http://localhost:64555/";
public readonly static string iOSAppName = "com.example.app";
public readonly static string AndroidAppName = "com.example.app";
public readonly static string iOSDeviceNameOrId = "iPad Pro (12.9-inch) (3rd generation)";
public readonly static string WebAssemblyDefaultUri = "http://localhost:5000/";
public readonly static string iOSAppName = "com.companyname.myextensionsapp";
public readonly static string AndroidAppName = "com.companyname.myextensionsapp";
public readonly static string iOSDeviceNameOrId = "iPad Pro (12.9-inch) (3rd generation)";

public readonly static Platform CurrentPlatform = Platform.Browser;
public readonly static Platform CurrentPlatform = Platform.Browser;
public readonly static Browser WebAssemblyBrowser = Browser.Chrome;
}
8 changes: 0 additions & 8 deletions src/Uno.Templates/content/unolib-uitest/Given_MainPage.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
//-:cnd:noEmit
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NUnit.Framework;
using Uno.UITest.Helpers.Queries;
using Query = System.Func<Uno.UITest.IAppQuery, Uno.UITest.IAppQuery>;

namespace UnoUITestsLibrary;

Expand Down
12 changes: 12 additions & 0 deletions src/Uno.Templates/content/unolib-uitest/GlobalUsings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//-:cnd:noEmit
#if (useFluentAssertions)
global using FluentAssertions;
#endif
#if (useShouldly)
global using Shouldly;
#endif
global using NUnit.Framework;
global using Uno.UITest;
global using Uno.UITest.Helpers.Queries;
global using Uno.UITests.Helpers;
global using Query = System.Func<Uno.UITest.IAppQuery, Uno.UITest.IAppQuery>;
6 changes: 0 additions & 6 deletions src/Uno.Templates/content/unolib-uitest/TestBase.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
//-:cnd:noEmit
using System;
using System.IO;
using NUnit.Framework;
using Uno.UITest;
using Uno.UITest.Selenium;
using Uno.UITests.Helpers;

namespace UnoUITestsLibrary;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@
</PropertyGroup>

<ItemGroup>
<!--#if (useFluentAssertions)-->
<PackageReference Include="FluentAssertions" VersionOverride="$FluentAssertions$" />
<!--#endif-->
<!--#if (useShouldly)-->
<PackageReference Include="Shouldly" VersionOverride="$ShouldlyVersion$" />
<!--#endif-->
<PackageReference Include="Microsoft.NET.Test.Sdk" VersionOverride="$MicrosoftTestSdk$" />
<PackageReference Include="Newtonsoft.Json" VersionOverride="$NewtonsoftJson$" />
<PackageReference Include="NUnit" VersionOverride="$NUnit$" />
Expand Down
Loading