Skip to content
Open
Show file tree
Hide file tree
Changes from 3 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
3 changes: 0 additions & 3 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,12 @@
<!-- Testing packages -->
<PackageVersion Include="Aspire.Hosting.Testing" Version="$(AspireVersion)" />
<PackageVersion Include="Bogus" Version="35.6.3" />
<PackageVersion Include="coverlet.collector" Version="6.0.4" />
<PackageVersion Include="OpenFeature.Contrib.Providers.Flagd" Version="0.3.3" />
<PackageVersion Include="OpenFeature.Providers.Ofrep" Version="0.1.2" />
<PackageVersion Include="MartinCostello.Logging.XUnit.v3" Version="0.6.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
<PackageVersion Include="xunit.v3.mtp-v2" Version="3.2.0" />
<PackageVersion Include="xunit.v3.assert" Version="3.2.0" />
<PackageVersion Include="xunit.v3.extensibility.core" Version="3.2.0" />
<PackageVersion Include="xunit.runner.visualstudio" Version="3.1.5" />
<PackageVersion Include="Microsoft.DotNet.XUnitV3Extensions" Version="11.0.0-beta.25509.1" />
<PackageVersion Include="Microsoft.Testing.Extensions.CodeCoverage" Version="18.1.0" />
<PackageVersion Include="Microsoft.Testing.Extensions.TrxReport" Version="2.0.2" />
Expand Down
3 changes: 3 additions & 0 deletions global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{
"sdk": {
"allowPrerelease": true
},
"test": {
"runner": "Microsoft.Testing.Platform"
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ namespace CommunityToolkit.Aspire.Testing;
/// Marks a test or test class as requiring an authenticated external tool.
/// Adds a trait to propagate the required tool name to the xUnit pipeline.
/// </summary>
[TraitDiscoverer("CommunityToolkit.Aspire.Testing.RequiresAuthenticatedToolDiscoverer", "CommunityToolkit.Aspire.Testing")]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true)]
public sealed class RequiresAuthenticatedToolAttribute : Attribute, ITraitAttribute
public sealed class RequiresAuthenticatedToolAttribute : Attribute
{
/// <summary>Initializes a new instance of the <see cref="RequiresAuthenticatedToolAttribute"/> class.</summary>
/// <param name="toolName">The name of the external tool required for the test.</param>
Expand All @@ -34,4 +33,14 @@ public RequiresAuthenticatedToolAttribute(string toolName, string? reason = null

/// <summary>Gets a value indicating whether authenticated tools are supported in the current environment.</summary>
public static bool IsSupported => !PlatformDetection.IsRunningOnCI;

public IEnumerable<KeyValuePair<string, string>> GetTraits()
{
yield return new KeyValuePair<string, string>("RequiresTools", ToolName);

if (!IsSupported)
{
yield return new KeyValuePair<string, string>("category", "unsupported-platform");
}
}
}
10 changes: 2 additions & 8 deletions tests/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,8 @@

<ItemGroup>
<PackageReference Include="Aspire.Hosting.Testing" />
<PackageReference Include="coverlet.collector" />
<PackageReference Include="MartinCostello.Logging.XUnit.v3" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="xunit.v3.mtp-v2" />
<PackageReference Include="xunit.runner.visualstudio" />
<PackageReference Include="GitHubActionsTestLogger" />
<PackageReference Include="Microsoft.Testing.Extensions.CodeCoverage" />
<PackageReference Include="Microsoft.Testing.Extensions.TrxReport" />
Expand All @@ -35,14 +32,11 @@
<PropertyGroup>
<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
</PropertyGroup>

<PropertyGroup>
<OutputType>Exe</OutputType>
<UseMicrosoftTestingPlatformRunner>true</UseMicrosoftTestingPlatformRunner>
<!-- ignore exit code 8 (zero tests ran)
https://learn.microsoft.com/dotnet/core/testing/microsoft-testing-platform-exit-codes -->
<TestingPlatformCommandLineArguments>$(TestingPlatformCommandLineArguments) --ignore-exit-code 8 --filter-not-trait &quot;category=failing&quot;</TestingPlatformCommandLineArguments>

<UseMicrosoftTestingPlatformRunner>true</UseMicrosoftTestingPlatformRunner>
</PropertyGroup>

</Project>
Loading