Skip to content
This repository was archived by the owner on Oct 11, 2022. It is now read-only.

Commit be317d6

Browse files
bstoneyjayaranigarg
authored andcommitted
Added docs for dynamic data display name (#39)
* Added docs for dynamic data display name * Fixed typo
1 parent a49a4f3 commit be317d6

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

RFCs/006-DynamicData-Attribute.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,24 @@ In case, the property or method exists in a class other than the test class, an
7070
Please note that Enum `DynamicDataSourceType` is used to specify whether test data source is a property or method.
7171
Data source is considered as property by default.
7272

73+
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:
74+
75+
```csharp
76+
public static string GetCustomDynamicDataDisplayName(MethodInfo methodInfo, object[] data)
77+
{
78+
return string.Format("DynamicDataTestMethod {0} with {1} parameters", methodInfo.Name, data.Length);
79+
}
80+
81+
// Method GetCustomDynamicDataDisplayName can be used to provide a custom test name for test data with data driven test case.
82+
[DynamicData("ReusableTestDataProperty", DynamicDataDisplayName = "GetCustomDynamicDataDisplayName")]
83+
```
84+
85+
`DynamicDataDisplayNameDeclaringType` should be used in cases where the dynamic data display name method exists in a class other than the test class
86+
87+
```csharp
88+
[DynamicData("ReusableTestDataMethod", DynamicDataDisplayName = "GetCustomDynamicDataDisplayName", DynamicDataDisplayNameDeclaringType = typeOf(UnitTests))]
89+
```
90+
7391
### Benefits of using DynamicData attribute
7492
1. More than one tests can use the same test data, if required.
7593
2. Changes in the shared test data can be scoped to single place.

0 commit comments

Comments
 (0)