Home > OS >  How to run tests (coverage) for multiple packages in Go?
How to run tests (coverage) for multiple packages in Go?

Time:01-12

Project Structure:

-MakeFile
-DockerFileForLogging
-DockerFileForMonitor
-Logging
   -go files
   -go.mod 
-Monitor
   -go files
   -go.mod

When I try to generate and run test on this project, I get Main module does not contain package /*/**/.../Logging.

Command :

    go test -race -coverprofile=coverage.out ./logging/...
    go test -race -coverprofile=coverage.out ./monitor/...

Tried multiple commands but I keep getting different errors.

CodePudding user response:

Instead of using ..., I believe the correct one would be *

Like the example:

go test -race -coverprofile=coverage.out ./logging/*
go test -race -coverprofile=coverage.out ./monitor/*

In this documentation you can get some details to understand better.

https://tldp.org/LDP/GNU-Linux-Tools-Summary/html/x11655.htm

  •  Tags:  
  • Related