Skip to content

Allow dotnet test --list-tests json #49754

@Youssef1313

Description

@Youssef1313

This is a feature request to allow producing the tests as json.

This is quite similar to microsoft/testfx#4130 but still different. The ask here is to produce more information about the tests as a JSON payload. See for example here how dotnet/aspire is manually parsing a the non-machine readable output today, which feels to me it's very fragile approach. We could output for each test:

  • fully qualified type name, including arity and nesting (e.g, MyNamespace.MyTestClass+MyNestedTestClass`2)
  • method name, e.g: MyTestMethod
  • method arity (probably only show it if generic)
  • traits as key-value pairs.
  • TestNodeUid

Maybe we can consider also modeling test methods under the classes. So in the JSON we will have an array of test classes, and each test class will have an array child for test methods. In C#, we can represent it as following:

public class RootObject
{
    public TestClassInfo[] TestClasses { get; set; }
}

public class TestClassInfo
{
    public string FullyQualifiedTypeName { get; set; }
    public TestMethodInfo[] TestMethods { get; set; }
}

public class TestMethodInfo
{
    public string TestNodeUid { get; set; }
    public string MethodName { get; set; }
    public string MethodArity { get; set; }
    public KeyValuePair<string, string>[] Traits { get; set; }
}

It's not very clear to me if this is more suited to be implemented in .NET SDK or in MTP itself.

NOTE: The command should fail if TestMethodIdentifierProperty isn't set by frameworks.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions