Skip to content

keploy/go-sdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Keploy Go Coverage Agent

This package enables native Go coverage reporting for tests generated by Keploy enterprise. It works by listening for commands from the Keploy binary to start and stop coverage collection for each test case.

How to Use

To integrate the coverage agent into your Go application, follow these two steps:

1. Activate the Agent

Add a blank import for the package in your application's main entry point (e.g., in your main.go file). This import's side effects will automatically initialize and run the coverage agent in the background.

import (
	// ... other imports
	_ "github.com/keploy/go-sdk/v3/keploy"
)

2. Build with Coverage Flags

Compile your application using the -cover and -covermode=atomic flags. These are required for the agent to access and clear coverage data for each test run according to https://pkg.go.dev/runtime/[email protected]#ClearCounters

go build -cover -covermode=atomic -o your-app .

3. Run tests with Keploy enterprise version

sudo -E keploy-enterprise test -c "./your-app" --dedup

Now you will see dedupData.yaml getting created.

Run sudo -E keploy-enterprise dedup to get the tests which are duplicate in duplicates.yaml file

In order to remove the duplicate tests, run the following command:

sudo -E keploy-enterprise dedup --rm