CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/golang-github-com-onsi-ginkgo-v2

A mature testing framework for Go designed to help you write expressive specs

Overall
score

97%

Overview
Eval results
Files

task.mdevals/scenario-6/

Test Suite Build Configuration Tool

Create a command-line tool that runs test suites with advanced build configurations. The tool should support various compilation and execution flags.

Requirements

Build a CLI application called testrunner that accepts command-line flags and executes test suites with the specified build configurations:

Supported Flags

  1. --race - Enable race detector during test execution
  2. --cover - Enable code coverage tracking and generate coverage profiles
  3. --tags - Support conditional compilation with custom build tags (e.g., --tags "integration,e2e")
  4. --ldflags - Pass custom flags to the linker during compilation (e.g., --ldflags "-X main.version=1.0.0")

Basic Behavior

  • Run tests in the current directory by default
  • Support recursive test execution with a --recursive or -r flag
  • Display clear output showing test results
  • Exit with status code 0 on success, non-zero on failure

Output

When coverage is enabled, the tool should:

  • Generate a coverage profile file named coverage.out
  • Display coverage statistics after test completion

Implementation Notes

  • Use Go's standard testing infrastructure
  • The tool should be executable from the command line
  • Handle errors gracefully with informative messages
  • Support combining multiple flags in a single execution

Dependencies { .dependencies }

github.com/onsi/ginkgo/v2 { .dependency }

A mature BDD testing framework for Go that provides sophisticated test execution capabilities and CLI tooling.

Test Cases

Test 1: Basic execution with race detection @test

# Create a test file: calculator_test.go
package calculator_test

import (
	"testing"

	. "github.com/onsi/ginkgo/v2"
	. "github.com/onsi/gomega"
)

func TestCalculator(t *testing.T) {
	RegisterFailHandler(Fail)
	RunSpecs(t, "Calculator Suite")
}

var _ = Describe("Calculator", func() {
	It("should add numbers correctly", func() {
		result := 2 + 2
		Expect(result).To(Equal(4))
	})
})
# Run the testrunner with race detection enabled
./testrunner --race

# Expected: Tests should run successfully with race detector enabled
# Output should indicate tests passed

Test 2: Enable coverage with profile generation @test

# Using the same test file from Test 1
# Run with coverage enabled
./testrunner --cover

# Expected:
# - Tests should run successfully
# - A file named 'coverage.out' should be created
# - Coverage statistics should be displayed in output

Test 3: Use build tags for conditional compilation @test

# Create integration_test.go with build tag
//go:build integration
// +build integration

package calculator_test

import (
	. "github.com/onsi/ginkgo/v2"
	. "github.com/onsi/gomega"
)

var _ = Describe("Integration Tests", func() {
	It("should run only with integration tag", func() {
		Expect(true).To(BeTrue())
	})
})
# Run tests with integration build tag
./testrunner --tags integration

# Expected: Both regular tests and integration tests should run

Test 4: Combine multiple build flags @test

# Using test files from previous tests
# Run with multiple flags combined
./testrunner --race --cover --tags integration

# Expected:
# - Tests run with race detection
# - Coverage profile generated
# - Tests with 'integration' tag included
# - All tests should pass

Files to Create

  • main.go - The CLI application entry point
  • testrunner_test.go - Test file demonstrating the tool works correctly

Install with Tessl CLI

npx tessl i tessl/golang-github-com-onsi-ginkgo-v2

tile.json