diff --git a/RFCs/006-DynamicData-Attribute.md b/RFCs/006-DynamicData-Attribute.md index eeb528d..cb2233d 100644 --- a/RFCs/006-DynamicData-Attribute.md +++ b/RFCs/006-DynamicData-Attribute.md @@ -70,6 +70,24 @@ In case, the property or method exists in a class other than the test class, an Please note that Enum `DynamicDataSourceType` is used to specify whether test data source is a property or method. Data source is considered as property by default. +Optionally, to provide a custom name for each data driven test case, `DynamicDataDisplayName` can be used to reference a public static method declared as below: + +```csharp + public static string GetCustomDynamicDataDisplayName(MethodInfo methodInfo, object[] data) + { + return string.Format("DynamicDataTestMethod {0} with {1} parameters", methodInfo.Name, data.Length); + } + + // Method GetCustomDynamicDataDisplayName can be used to provide a custom test name for test data with data driven test case. + [DynamicData("ReusableTestDataProperty", DynamicDataDisplayName = "GetCustomDynamicDataDisplayName")] +``` + +`DynamicDataDisplayNameDeclaringType` should be used in cases where the dynamic data display name method exists in a class other than the test class + +```csharp + [DynamicData("ReusableTestDataMethod", DynamicDataDisplayName = "GetCustomDynamicDataDisplayName", DynamicDataDisplayNameDeclaringType = typeOf(UnitTests))] +``` + ### Benefits of using DynamicData attribute 1. More than one tests can use the same test data, if required. 2. Changes in the shared test data can be scoped to single place.