Home > Enterprise >  check whether test function will run in parallel
check whether test function will run in parallel

Time:01-11

How can I check whether a *testing.T has been set to run in parallel?

Ideally the solution might be:

func isParellelT(t *testing.T) bool {
   // return some means to figure t has called t.Parallel().
}

CodePudding user response:

testing.T does not make this information available. Your tests should not depend on it. If you want to do this, you almost certainly should do something else instead.

However, it is possible to access the private data using reflection, or derive it by checking whether testing.T.SetEnv panics

  • Related