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

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

Closed
imiskolee opened this issue Mar 10, 2020 · 2 comments
Closed

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

imiskolee opened this issue Mar 10, 2020 · 2 comments

Comments

@imiskolee
Copy link

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.

@toothrot toothrot changed the title feature request - export all test case into human friendly format. testing: feature request - export all test case into human friendly format. Mar 10, 2020
@toothrot toothrot changed the title testing: feature request - export all test case into human friendly format. proposal: testing: export all test case into human friendly format. Mar 10, 2020
@gopherbot gopherbot added this to the Proposal milestone Mar 10, 2020
@mvdan
Copy link
Member

mvdan commented Mar 10, 2020

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.

@rsc
Copy link
Contributor

rsc commented Mar 11, 2020

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

@rsc rsc closed this as completed Mar 11, 2020
@rsc rsc added this to Declined in Proposals (old) Mar 11, 2020
@golang golang locked and limited conversation to collaborators Mar 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
No open projects
Development

No branches or pull requests

4 participants