brainstorming
brainstorming
You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation).
software-testing-best-practicesExplains various software testing methodologies including unit testing, integration testing, and system testing with best practices.
Independent GitHub snapshot · Automated classification · Original documentation governs
name: software-testing-best-practices description: Explains various software testing methodologies including unit testing, integration testing, and system testing with best practices. license: MIT compatibility: opencode metadata: version: "1.0.0" domain: software triggers: unit testing, integration testing, system testing, testing methodologies, testing frameworks role: implementation scope: implementation output-format: code related-skills: software-architecture-overview, software-development-lifecycle archetypes: tactical anti_triggers: manual tests, ad-hoc testing response_profile: { verbosity: high, directive_strength: high, abstraction_level: tactical }
This skill covers the best practices in software testing methodologies, helping teams to implement rigorous testing strategies throughout the software lifecycle.
Select Testing Framework
Choose a framework suitable for the project based on language and requirements. For example, choose JUnit for Java, or NUnit for .NET applications.
Implement Unit Tests
Write unit tests to validate individual components.
Example in Python using unittest framework:
import unittest
class TestSum(unittest.TestCase):
def test_sum(self):
self.assertEqual(sum([1, 2, 3]), 6)
if __name__ == '__main__':
unittest.main()
Create Integration Tests
Validate interactions between multiple components.
Example using pytest for integration tests:
# test_integration.py
def test_integration():
assert function_a() == expected_output
System Testing
Conduct system tests to verify the complete and integrated software product. This includes regression testing and performance testing.
Continuous Testing
Integrate tests into the CI/CD pipeline for ongoing verification throughout the development lifecycle.
Example command to run tests in Docker:
docker run mytestcontainer pytest
# GitHub Actions workflow for automated testing
name: Run Tests
on:
push:
branches:
- main
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
- run: |
pip install -r requirements.txt
pytest
Testcontainers spins up real service dependencies (PostgreSQL, Redis, etc.) inside Docker containers for true integration testing:
import pytest
from testcontainers.postgres import PostgresContainer
from sqlalchemy import create_engine, text
@pytest.fixture(scope="module")
def postgres_container():
"""Spin up a real PostgreSQL instance in Docker."""
with PostgresContainer("postgres:16-alpine") as pg:
engine = create_engine(pg.get_connection_url())
# Run migrations
with engine.begin() as conn:
conn.execute(text("CREATE TABLE users (id SERIAL PRIMARY KEY, name TEXT)"))
conn.execute(text("INSERT INTO users (name) VALUES ('Alice')"))
yield engine
def test_database_query(postgres_container):
"""Verify we can query the real database."""
with postgres_container.begin() as conn:
result = conn.execute(text("SELECT name FROM users"))
names = [row[0] for row in result]
assert "Alice" in names
assert len(names) == 1
Authoritative documentation links for this skill's domain. The model follows markdown links to resolve external references and inline content.