Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
12 changes: 11 additions & 1 deletion src/TUnit.Engine/Discovery/ReflectionAttributeExtractor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,17 @@ public static Attribute[] GetAllAttributes(Type testClass, MethodInfo testMethod

// Add in reverse order of precedence so method attributes come first
// This ensures ScopedAttributeFilter will keep method-level attributes over class/assembly
attributes.AddRange(key.Item2.GetCustomAttributes());
// Method-level data source attributes are left out, matching the source generator. The
// data source that produced each test case is appended per test by the TestBuilder, so
// per-row settings such as [Arguments(Skip = "...")] only apply to their own row.
foreach (var attribute in key.Item2.GetCustomAttributes())
{
if (attribute is not IDataSourceAttribute)
Comment thread
thomhurst marked this conversation as resolved.
Resolved
Comment thread
thomhurst marked this conversation as resolved.
Resolved
Comment thread
thomhurst marked this conversation as resolved.
Resolved
Comment thread
thomhurst marked this conversation as resolved.
Resolved
Comment thread
thomhurst marked this conversation as resolved.
Resolved
{
attributes.Add(attribute);
}
}

attributes.AddRange(key.Item1.GetCustomAttributes());
attributes.AddRange(key.Item1.Assembly.GetCustomAttributes());

Expand Down
35 changes: 35 additions & 0 deletions tests/TUnit.Engine.Tests/Issue7076Tests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using Shouldly;
using TUnit.Engine.Tests.Enums;

namespace TUnit.Engine.Tests;

public class Issue7076Tests(TestMode testMode) : InvokableTestBase(testMode)
{
[Test]
public async Task Arguments_Skip_Only_Skips_Its_Own_Row()
{
await RunTestsWithFilter(
"/*/*/ArgumentsRowSkipTests/OnlyMarkedRowIsSkipped",
[
result => result.ResultSummary.Outcome.ShouldBe("Completed"),
result => result.ResultSummary.Counters.Total.ShouldBe(3),
result => result.ResultSummary.Counters.Passed.ShouldBe(2),
result => result.ResultSummary.Counters.Failed.ShouldBe(0),
result => result.ResultSummary.Counters.NotExecuted.ShouldBe(1)
]);
}

[Test]
public async Task Arguments_DisplayName_Only_Applies_To_Its_Own_Row()
{
await RunTestsWithFilter(
"/*/*/ArgumentsRowSkipTests/DisplayNameOnlyAppliesToItsOwnRow",
[
result => result.ResultSummary.Outcome.ShouldBe("Completed"),
result => result.ResultSummary.Counters.Total.ShouldBe(2),
result => result.ResultSummary.Counters.Passed.ShouldBe(2),
result => result.ResultSummary.Counters.Failed.ShouldBe(0),
result => result.ResultSummary.Counters.NotExecuted.ShouldBe(0)
]);
}
}
33 changes: 33 additions & 0 deletions tests/TUnit.TestProject/Bugs/_7076/ArgumentsRowSkipTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using TUnit.TestProject.Attributes;

namespace TUnit.TestProject.Bugs._7076;

[EngineTest(ExpectedResult.Pass)]
public class ArgumentsRowSkipTests
{
[Test]
[Arguments("a")]
[Arguments("b")]
[Arguments("c", Skip = "skip only c")]
public async Task OnlyMarkedRowIsSkipped(string value)
Comment thread
thomhurst marked this conversation as resolved.
Resolved
{
await Assert.That(value).IsNotEqualTo("c");
}

[Test]
[Arguments(1, DisplayName = "custom name for 1")]
[Arguments(2)]
public async Task DisplayNameOnlyAppliesToItsOwnRow(int value)
{
var displayName = TestContext.Current!.Metadata.DisplayName;

if (value == 1)
{
await Assert.That(displayName).IsEqualTo("custom name for 1");
}
else
{
await Assert.That(displayName).IsNotEqualTo("custom name for 1");
Comment thread
thomhurst marked this conversation as resolved.
Resolved
}
}
}
Loading