You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
proposal: testing: export all test case into human friendly format. #37770
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 functionfuncTestFooBar(t*testing.T) {
///Comment for test case At.Run("Test Case A",func (t*testing.T) {
///Comment for test case 1t.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"
}
]
},
...
]
}
]
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
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
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.
Activity
[-]feature request - export all test case into human friendly format.[/-][+]testing: feature request - export all test case into human friendly format.[/+][-]testing: feature request - export all test case into human friendly format.[/-][+]proposal: testing: export all test case into human friendly format.[/+]mvdan commentedon 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:
This is why
go test -listonly 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 commentedon Mar 11, 2020
As @mvdan points out, this is impossible to implement, since subtests can be computed.
Declining the proposal as infeasible.