Skip to content

Conversation

@delatrie
Copy link
Contributor

@delatrie delatrie commented Aug 5, 2025

Context

In some cases, assembly-qualified names are included in fullName values of NUnit test results, which leads to two problems:

  1. The values become way too verbose (especially given that TestOps has a limit of 255 characters).
  2. The values become dependent on assembly versions. For example, int's assembly-qualified name includes the version of the target framework (e.g., System.Int32, System.Private.CoreLib, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e). That means, this name changes each time the tests are compiled against a new version of .NET.

An example of a context where such an issue occurs is a test with a parameter of a generic type:

Example

Given the following test:

using System.Collections.Generic;
using Allure.NUnit;
using NUnit.Framework;

[AllureNUnit]
public class MyTests
{
    [TestCaseSource(nameof(Parameters))]
    public void Foo(List<string> bar)
    {

    }

    public static IEnumerable<List<string>> Parameters => [ [ "Lorem", "Ipsum" ] ];
}

When run, the result of such a test will receive the following fullName:

MyAssembly:MyTests.Foo(System.Collections.Generic.List`1[[System.String, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]][System.String])

Here, the [[System.String, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]] part is both framework-dependent (Version=8.0.0.0 of System.Private.CoreLib corresponds to .NET 8.0) and redundant (it follows by a more compact yet sufficient name of the type, System.String).

Solution

The reason this behavior occurs is that we use System.Type.FullName when calculating full names. This PR precludes it.

Fixes #418.

Checklist

@delatrie delatrie added the type:bug Something isn't working label Aug 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

theme:core type:bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NUnit: Test methods with parameters of generic types get version-dependent full names

3 participants