<PackageReference Include="NUnit" Version="4.1.0" />

PropertyAttribute

Attaches information to a test assembly, fixture or method as a name/value pair.
using NUnit.Framework.Interfaces; using NUnit.Framework.Internal; using System; using System.Runtime.CompilerServices; namespace NUnit.Framework { [System.Runtime.CompilerServices.NullableContext(1)] [System.Runtime.CompilerServices.Nullable(0)] [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true, Inherited = true)] public class PropertyAttribute : NUnitAttribute, IApplyToTest { private readonly PropertyBag _properties = new PropertyBag(); public IPropertyBag Properties => _properties; public PropertyAttribute(string propertyName, string propertyValue) { _properties.Add(propertyName, propertyValue); } public PropertyAttribute(string propertyName, int propertyValue) { _properties.Add(propertyName, propertyValue); } public PropertyAttribute(string propertyName, double propertyValue) { _properties.Add(propertyName, propertyValue); } protected PropertyAttribute() { } protected PropertyAttribute(object propertyValue) { string text = GetType().Name; if (text.EndsWith("Attribute", StringComparison.Ordinal)) text = text.Substring(0, text.Length - 9); _properties.Add(text, propertyValue); } public virtual void ApplyToTest(Test test) { foreach (string key in Properties.Keys) { foreach (object item in Properties[key]) { test.Properties.Add(key, item); } } } } }