What would be the best approach to display the Enum names and not the values #2560
-
Hi, I am using Allure with C# and NUnit. I want to display the Enum name and not the value to improve the readability of the logs. This is a code example:
The actual result in the Logs is something like this: |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
The right way would be to use the type formatters API: using Allure.Net.Commons;
class ToStringTypeFormatter<T> : TypeFormatter<T>
{
public string Format(T value) => value?.ToString();
} Then, define a setup fixture in the root namespace (or no namespace at all): using NUnit.Framework;
using Allure.Net.Commons;
[SetUpFixture]
public class MySetup
{
[OneTimeSetUp]
public void SetupAllure()
{
AllureLifecycle.AddTypeFormatter(new ToStringTypeFormatter<InterestType>());
}
} Moreover, I believe that should be the default behavior for enums and some other types. I've created an issue and hopefully, will fix that later: allure-framework/allure-csharp#502 |
Beta Was this translation helpful? Give feedback.
The right way would be to use the type formatters API:
Then, define a setup fixture in the root namespace (or no namespace at all):
Moreover, I believe that should be the default behavior for enums and some other types. I've created an issue and hopefully, will fix that later: allure-framework/allure-csharp#502