Bird
Raised Fist0
Testing Fundamentalstesting~8 mins

Shift-left testing in Testing Fundamentals - Framework Patterns

Choose your learning style10 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.

Practice

(1/5)
1. What is the main idea behind shift-left testing?
easy
A. Testing only the user interface at the end
B. Testing early in the software development process
C. Testing only after the software is fully developed
D. Testing only by the quality assurance team

Solution

  1. Step 1: Understand the term 'shift-left'

    Shift-left means moving testing activities to earlier stages in development.
  2. Step 2: Compare options with the definition

    Only Testing early in the software development process describes testing early, others describe late or limited testing.
  3. Final Answer:

    Testing early in the software development process -> Option B
  4. Quick Check:

    Shift-left = Early testing [OK]
Hint: Shift-left means test early, not late [OK]
Common Mistakes:
  • Thinking testing happens only after coding
  • Confusing shift-left with testing only UI
  • Believing only QA team tests
2. Which of the following is a common practice that supports shift-left testing?
easy
A. Writing tests after the product release
B. Performing only manual testing at the end
C. Test-driven development (TDD)
D. Skipping code reviews

Solution

  1. Step 1: Identify practices that enable early testing

    TDD means writing tests before or during coding, supporting early testing.
  2. Step 2: Eliminate options that delay or skip testing

    Options A, B, and C delay or reduce testing, not shift it left.
  3. Final Answer:

    Test-driven development (TDD) -> Option C
  4. Quick Check:

    TDD = Early testing practice [OK]
Hint: TDD means write tests first, fits shift-left [OK]
Common Mistakes:
  • Thinking tests come only after release
  • Ignoring code reviews as testing support
  • Believing manual testing only is enough
3. Consider this code snippet representing a testing timeline:
Development Start -> Code Review -> Unit Testing -> Integration Testing -> Release

Which step best represents the shift-left testing approach?
medium
A. Unit Testing
B. Release
C. Code Review
D. Integration Testing

Solution

  1. Step 1: Understand shift-left means testing early

    Shift-left moves testing activities closer to development start.
  2. Step 2: Identify earliest testing-related step

    Unit Testing is the earliest formal testing phase after code review, which is a review step but not a testing activity.
  3. Final Answer:

    Unit Testing -> Option A
  4. Quick Check:

    Shift-left = Early testing phases like unit testing [OK]
Hint: Shift-left means test as early as possible [OK]
Common Mistakes:
  • Choosing testing steps that happen later
  • Confusing release with testing
  • Ignoring code review as testing support
4. A team claims they follow shift-left testing but only start testing after full coding is done. What is the main problem in their approach?
medium
A. They are not testing early enough
B. They are testing too early
C. They are using too many automated tests
D. They are skipping integration testing

Solution

  1. Step 1: Recall shift-left means testing early

    Testing after full coding is late, not early.
  2. Step 2: Identify the problem with their timing

    The team delays testing, so they miss shift-left benefits.
  3. Final Answer:

    They are not testing early enough -> Option A
  4. Quick Check:

    Shift-left = test early, not late [OK]
Hint: Shift-left means test early, not after coding done [OK]
Common Mistakes:
  • Thinking testing too early is a problem
  • Confusing automation with timing
  • Ignoring integration testing relevance
5. A project uses shift-left testing by integrating automated unit tests early. However, bugs still appear late in integration testing. What is a likely cause?
hard
A. Manual testing should replace automated tests
B. Automated tests are run too early in development
C. Shift-left testing means skipping integration tests
D. Unit tests do not cover integration points between modules

Solution

  1. Step 1: Understand shift-left testing scope

    Shift-left encourages early testing but does not replace integration testing.
  2. Step 2: Analyze why bugs appear late despite early unit tests

    Unit tests check individual parts but may miss how parts work together.
  3. Step 3: Identify the cause of late bugs

    Missing coverage of integration points causes bugs to appear late.
  4. Final Answer:

    Unit tests do not cover integration points between modules -> Option D
  5. Quick Check:

    Early unit tests ≠ full integration coverage [OK]
Hint: Unit tests check parts, integration tests check connections [OK]
Common Mistakes:
  • Thinking shift-left skips integration testing
  • Believing running tests early causes bugs
  • Replacing automated tests with manual only
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard