Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test Display Name should be Extensible #515

Closed
ahmedalejo opened this issue Nov 9, 2018 · 4 comments
Closed

Test Display Name should be Extensible #515

ahmedalejo opened this issue Nov 9, 2018 · 4 comments
Labels
Help-Wanted The issue is up-for-grabs, and can be claimed by commenting

Comments

@ahmedalejo
Copy link

Description
Following the extensibility initiative in MsTest V2. It would help to be able to define Display Names (i.e TestName) for tests thereby making human-readable(serves as better documentation of codebase as well) names that show up in the test explorer .

Test frameworks like xUnit this via configuration xunit/xunit#759

Expected behavior

[TestMethod("Consecutive authentication attempts with invalid credentials should fail")]
public void MyTest()
{ ... }
//or

[MyAppTestMethod]
public void Consecutive_authentication_attempts_with_invalid_credentials_should_fail()
{ ... }

//Given the following definitions
public class TestMethodAttrubte : Attribute
{
    public string DisplaName { get; set; }

    public virtual string GetDisplayName(System.Reflection.MethodInfo methodInfo) =>
        string.IsNullOrWhiteSpace(this.DisplaName) 
        ? methodInfo.Name 
        : this.DisplaName?.Trim();

   ...
}

public class MyAppsTestMethodAttrubte : TestMethodAttrubte
{
    public override string GetDisplayName(MethodInfo methodInfo) =>
        methodInfo
            .Name
            .Replace("_", " ")
            .Replace(".", ", ");
}

image

Actual behavior
The display name is "machine" readable.
image

This proposal is also similar to #410

@ahmedalejo ahmedalejo changed the title Allow Test Display Name to be Extensible Make Test Display Name Extensible Nov 9, 2018
@ahmedalejo ahmedalejo changed the title Make Test Display Name Extensible Test Display Name should be Extensible Nov 9, 2018
@karanjitsingh karanjitsingh added enhancement Help-Wanted The issue is up-for-grabs, and can be claimed by commenting labels Nov 9, 2018
@karanjitsingh
Copy link
Contributor

Hi @ahmedalejo, thanks for suggesting that. I've marked this as an enhancement and we'll be happy to accept any contribution.

@jadaml
Copy link

jadaml commented Nov 23, 2019

It might be me reading GitHub incorrectly, but I do not quite understand what is the decision here; are you saying that the feature request—to apply a display name altering the test case name displayed—is the same as #644 or it was just mentioned there and the decision is then ... what exactly?

@ahmedalejo
Copy link
Author

@jadaml like metioned in #644,

Merging #644 would complement the implementation of #515, i.e if or when it is done.

@jadaml
Copy link

jadaml commented Jan 26, 2020

So the decision is then is that you'll solve these two under the same issue, as both issues affects the display of the test, but both method of controlling the name (prettifying the method name, and overriding it with an attribute) will be available in the end?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Help-Wanted The issue is up-for-grabs, and can be claimed by commenting
Projects
None yet
Development

No branches or pull requests

3 participants