I have a bunch of tests I would like to run in parallel; I think this is a 
common situation for database backed tests where you might need to 
establish a connection or a transaction, run a bunch of queries, and then 
truncate the database. Right now I have something like this:

func testA(t *testing.T) { t.Parallel(); ... }

func testB(t *testing.T) { t.Parallel(); ... }

func testC(t *testing.T) { t.Parallel(); ... }

func testD(t *testing.T) { t.Parallel(); ... }

func TestAll(t *testing.T) {
    setUp(t)
    defer tearDown(t)
    t.Run("parallel", func(t *testing.T) {
        t.Run("TestA", testA)
        t.Run("TestB", testB)
        t.Run("TestC", testC)
        t.Run("TestD", testD)
    })
}

However there's some duplication there. 

- Is there a way to avoid the extra level of Run() nesting? It's a little 
annoying when specifying a command to `go test -run`.

- Is there any way to automatically populate the test name from the 
function name? I could probably hack up something with the reflect package 
based on the function name but that would also be pretty ugly, I'm guessing.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to