gotestyourself / gotestsum

'go test' runner with output optimized for humans, JUnit XML for CI integration, and a summary of the test results.
Apache License 2.0
1.99k stars 118 forks source link

gotestsum support to run multiple tests using fully qualified name of tests #408

Open triptijain2112 opened 1 month ago

triptijain2112 commented 1 month ago

Hi all,

I am trying to run a similar below command in gotestsum to run multiple tests using fully qualified name of tests:

go repo: https://github.com/yakuter/go-test-examples go test go.mod/01-normal -v -run ^Test11$ && go test go.mod/04-testmain -v -run ^Test1$

Any suggestions how to combine these 2 commands?

triptijain2112 commented 1 month ago
  1. Is there a way to combine these 2 commands in one go test command? go test go.mod/01-normal -v -run ^Test11$ && go test go.mod/04-testmain -v -run ^Test1$

  2. How to fix this command? go test go.mod/04-testmain -v -run ^Test1$ | gotestsum --junitfile unit-tests1.xml

dnephin commented 1 month ago

Hello, try

gotestsum --junitfile unit-tests1.xml -- -run '^Test1$|Test11$' 
triptijain2112 commented 1 month ago

Hi @dnephin , Thanks for the suggestion, It helped!!

Do we have any way to combine the below 2 commands and generate one combined output xml file?

gotestsum --junitfile unit-tests2.xml -- go.mod/04-testmain -v -run "^Test1$" gotestsum --junitfile unit-tests2.xml -- go.mod/01-normal -v -run "^Test1$"

note: I want to provide package names to run selected tests in that package, not all tests from all packages that matches the regex.