Skip to content

proposal: testing: export all test case into human friendly format. #37770

Closed

Description

@imiskolee

Feature Request - Test Case Export

Hi, All:
As we know, Golang built-in a nice test solution now, but can't export test case without real to run.

In fact We're often want to export test case to a nice format then import to another test case management tool.

So, I am asking for a new feature to export test cases.

What did you do?

The test case sample

///coment for test function
func TestFooBar(t *testing.T) {
	///Comment for test case A
	t.Run("Test Case A",func (t *testing.T) {
		///Comment for test case 1
		t.Run("Test Case 1",func (t *testing.T) {

		})
		t.Run("Test Case 2",func (t *testing.T) {

		})
	})
	t.Run("Test Case B",func (t *testing.T) {
		t.Run("Test Case 1",func (t *testing.T) {

		})
		t.Run("Test Case 2",func (t *testing.T) {

		})
	})
}

What did you expect to see?

[
  {
     "name" : "TestFooBar",
     "comment" : "coment for test function",
     "sub" : [
        {
			"name" : "Test Case A",
  			"comment" : "Comment for test case A",
			"sub" : [
				{
						"name" : "Test Case 1",
  						"comment" : "Comment for test case 1",
				},
				{
						"name" : "Test Case 2"
				}
			]
		},
		...
     ]
  }
]

What did you see instead?

can't do it now.

Activity

  1. changed the title [-]feature request - export all test case into human friendly format.[/-] [+]testing: feature request - export all test case into human friendly format.[/+] on Mar 10, 2020
  2. changed the title [-]testing: feature request - export all test case into human friendly format.[/-] [+]proposal: testing: export all test case into human friendly format.[/+] on Mar 10, 2020
  3. added this to the Proposal milestone on Mar 10, 2020
  4. mvdan commented on Mar 10, 2020

    @mvdan
    Member

    A Go test with sub-tests is not a graph or table, though. You can have arbitrary code and logic. For example, this is common:

    for _, test := range testTable {
        t.Run(test.name, func(t *testing.T) {
            // ...
        })
    }
    

    This is why go test -list only lists top-level tests, and not sub-tests. Listing all sub-tests requires actually executing the tests, and might not show subtests which aren't meant to run on your platform.

  5. rsc commented on Mar 11, 2020

    @rsc
    Contributor

    As @mvdan points out, this is impossible to implement, since subtests can be computed.
    Declining the proposal as infeasible.

  6. locked and limited conversation to collaborators on Mar 11, 2021
  7. moved this to Declined in Proposalson Aug 10, 2022
  8. removed this from Proposalson Oct 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions