run-tests

Use this skill when running or writing tests for this project.

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "run-tests" with this command: npx skills add sjtw/tarkov-build-optimiser/sjtw-tarkov-build-optimiser-run-tests

Run Tests Skill

Use this skill when running or writing tests for this project.

Test Types

This project uses filename and function name conventions for test categorization:

  • Unit tests: Files without "Integration" in test function names. No external dependencies, fast.

  • Integration tests: *_integration_test.go files with "Integration" in function names. Requires database, slower.

  • Benchmarks: Standard Go benchmarks (func Benchmark... ). See internal/evaluator/evaluator_benchmark_test.go for an example.

When to Use Each

Unit Tests (task test:unit )

Use when:

  • Doing TDD or tight iteration loops

  • Testing pure functions or business logic

  • No database or network calls needed

  • Want fast feedback (runs in seconds)

Command:

task test:unit

What it runs:

go test ./... -run "Test[^I]"

This runs all tests that don't have "Integration" in the name.

Example test files:

  • internal/helpers/maths_test.go

  • internal/candidate_tree/item_test.go

  • internal/evaluator/trader_constraints_test.go

Integration Tests (task test:integration )

Use when:

  • Testing database operations (models package)

  • Testing full workflows that span multiple components

  • Verifying migrations work correctly

  • Before merging to main

Commands:

Recommended for DevContainer (assuming database is running)

task test:integration

Use if database needs to be started via Docker Compose

task test:integration:docker

What it does:

  • test:integration : Runs tests matching .Integration. pattern.

  • test:integration:docker : Starts Docker services (PostgreSQL) via compose:up , then runs integration tests.

What it runs:

go test ./... -run ".Integration."

Example test files:

  • internal/evaluator/find_best_build_integration_test.go

  • internal/db/db_test.go

Requirements:

  • Docker running

  • .env file configured

  • Database migrations applied

All Tests (task test )

Use when:

  • Running CI/CD pipeline

  • Final verification before pushing

  • Want comprehensive coverage check

Command:

task test

What it runs:

go test ./...

Runs everything: unit, integration, and any other tests.

Test Workflow Recommendations

During Active Development (TDD)

Run unit tests repeatedly after changes

task test:unit

Before Committing

Run unit tests (fast check)

task test:unit

If touching database code, run integration tests

task test:integration

Before Pushing/Merging

Run everything

task test

Run linter too

task lint

Running Specific Tests

Single test function:

go test ./internal/evaluator -run TestFindBestBuild

Single package:

go test ./internal/evaluator/...

Verbose output:

go test -v ./...

With coverage:

go test -cover ./...

Writing New Tests

When creating tests, follow the naming convention:

// Unit test (no external dependencies) // File: internal/helpers/maths_unit_test.go func TestCalculateAverage(t *testing.T) { // ... }

// Integration test (uses database) // File: internal/models/weapons_integration_test.go func TestWeaponsIntegration(t *testing.T) { // ... }

Rules:

  • Unit tests: *_unit_test.go files, no database/network

  • Integration tests: *_integration_test.go files, function name must include "Integration"

  • Use table-driven tests for multiple cases

  • Keep tests focused and independent

Troubleshooting

Integration tests fail with connection error:

  • Ensure database is running.

  • Check .env has correct connection details.

  • In a devcontainer, the database is usually already running. Outside, you might need task compose:up .

Tests pass locally but fail in CI:

  • Ensure you're not relying on local state or files

  • Check if tests have proper cleanup

  • Verify tests are idempotent (can run multiple times)

Tests are slow:

  • Ensure unit tests aren't hitting the database

  • Check if you can mock external dependencies

  • Consider moving integration logic to integration test files

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

General

api-endpoint-pattern

No summary provided by upstream source.

Repository SourceNeeds Review
General

data-access-patterns

No summary provided by upstream source.

Repository SourceNeeds Review
General

use-taskfile

No summary provided by upstream source.

Repository SourceNeeds Review
General

create-migration

No summary provided by upstream source.

Repository SourceNeeds Review