A mature testing framework for Go designed to help you write expressive specs
Overall
score
97%
Create a command-line tool that runs test suites with advanced build configurations. The tool should support various compilation and execution flags.
Build a CLI application called testrunner that accepts command-line flags and executes test suites with the specified build configurations:
--tags "integration,e2e")--ldflags "-X main.version=1.0.0")--recursive or -r flagWhen coverage is enabled, the tool should:
coverage.outA mature BDD testing framework for Go that provides sophisticated test execution capabilities and CLI tooling.
# Create a test file: calculator_test.gopackage 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# 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# 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# 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 passmain.go - The CLI application entry pointtestrunner_test.go - Test file demonstrating the tool works correctlyInstall with Tessl CLI
npx tessl i tessl/golang-github-com-onsi-ginkgo-v2docs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10