-1

I know that I can specify which tests are meant to run by using -run flag like so:

go test -run=TestUpdateAll//Assignments

But how can I do that to make go test not run a particular test?

Let's say I don't wont the above test to be run. How to do that?

EDIT

Maybe this is crucial to understand my problem: the tests that I'd like to run are generated by third party tools with which I'm still trying to resolve an issue that's causing the above.

Therefore I cannot really add flags in source or use t.Skip() etc.

Patryk
  • 22,602
  • 44
  • 128
  • 244

1 Answers1

0

There's no direct way to do this (that doesn't involve constructing a regexp that matches everything except your set of tests), but you can add a flag yourself if you have a specific test (or set of tests) you'd like to skip frequently.

In your test file:

var skipPlz = flag.Bool("skip_assignments", false, "skip the assignments test")

func TestAssignments(t *testing.T) {
   if *skipPlz { t.Skip("-skip_assignments set") }
   .. remainder of test
}

With this code, you can run your go test command with the -skip_assignments flag to skip this test.

Paul Hankin
  • 54,811
  • 11
  • 92
  • 118
  • Thanks for your answer. Can you see my edit? That should shed some more light on my problem. – Patryk Mar 26 '20 at 11:53