Skip to content

What would be the best approach to display the Enum names and not the values #2560

Closed Answered by delatrie
kiragengis asked this question in Questions & Support
Discussion options

You must be logged in to vote

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

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by kiragengis
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants