0
0
Testing Fundamentalstesting~8 mins

Shift-left testing in Testing Fundamentals - Framework Patterns

Choose your learning style9 modes available
Framework Mode - Shift-left testing
Folder Structure for Shift-left Testing Framework
shift_left_testing_project/
├── src/
│   ├── main_code/          # Application source code
│   ├── unit_tests/         # Unit tests close to code
│   ├── integration_tests/  # Integration tests
│   ├── static_analysis/    # Static code analysis configs and scripts
│   └── test_utils/         # Helpers and utilities for tests
├── ci_cd_pipeline/         # CI/CD scripts and configs
├── docs/                   # Documentation about testing strategy
├── config/                 # Environment and test configs
│   ├── dev.env             # Development environment variables
│   ├── test.env            # Test environment variables
│   └── prod.env            # Production environment variables
└── reports/                # Test reports and logs
Test Framework Layers in Shift-left Testing
  • Source Code Layer: The main application code where developers write features.
  • Unit Test Layer: Tests written by developers to check small pieces of code immediately.
  • Integration Test Layer: Tests that check how different parts work together, done early.
  • Static Analysis Layer: Tools that check code quality and security before running tests.
  • Test Utilities Layer: Helper functions and mocks to support tests.
  • CI/CD Layer: Automated pipelines that run tests on every code change to catch issues early.
Configuration Patterns for Shift-left Testing
  • Environment Configs: Separate files for dev, test, and prod to run tests in correct settings.
  • Test Settings: Configurations to run only fast unit tests during early development.
  • Static Analysis Rules: Config files for linters and security scanners integrated into the pipeline.
  • Credential Management: Use secure storage or environment variables to keep secrets safe during tests.
Test Reporting and CI/CD Integration
  • Immediate Feedback: CI pipelines run unit and static analysis on every commit, showing pass/fail quickly.
  • Detailed Reports: Reports include code coverage, test results, and static analysis warnings.
  • Fail Fast: If unit tests or static analysis fail, the pipeline stops early to save time.
  • Integration with Tools: Use tools like Jenkins, GitHub Actions, or GitLab CI to automate and report.
Best Practices for Shift-left Testing Framework
  • Test Early and Often: Write and run unit tests as soon as code is written.
  • Automate Everything: Use CI pipelines to run tests and static analysis automatically on every change.
  • Keep Tests Fast: Prioritize quick tests early to get fast feedback.
  • Use Static Analysis: Catch bugs and security issues before running tests.
  • Maintain Clear Configs: Keep environment and test settings organized and separate.
Self Check Question

Where in this folder structure would you add a new unit test for a recently added function in the main code?

Key Result
Shift-left testing means running fast unit tests and static analysis early in development to catch issues quickly.