Bird
Raised Fist0
Testing Fundamentalstesting~10 mins

Shift-left testing in Testing Fundamentals - Test Execution Trace

Choose your learning style10 modes available
Test Overview

This test simulates a simple software development process where testing starts early (shift-left). It verifies that bugs are caught early during development rather than later in production.

Test Code - unittest
Testing Fundamentals
class SoftwareDevelopmentProcess:
    def __init__(self):
        self.code_written = False
        self.tests_run = False
        self.bugs_found = 0

    def write_code(self):
        self.code_written = True

    def run_tests_early(self):
        if not self.code_written:
            raise Exception("Cannot test before code is written")
        self.tests_run = True
        # Simulate finding bugs early
        self.bugs_found = 2

    def deploy(self):
        if not self.tests_run:
            # Bugs found late
            self.bugs_found = 5

import unittest

class TestShiftLeft(unittest.TestCase):
    def test_shift_left(self):
        process = SoftwareDevelopmentProcess()
        process.write_code()
        process.run_tests_early()
        process.deploy()
        # Assert bugs found early are fewer than if tested late
        self.assertLess(process.bugs_found, 5)

if __name__ == '__main__':
    unittest.main()
Execution Trace - 5 Steps
StepActionSystem StateAssertionResult
1Create SoftwareDevelopmentProcess instanceNew process object with no code written, no tests run, zero bugs found—PASS
2Call write_code() to simulate writing codeCode written flag set to True—PASS
3Call run_tests_early() to simulate early testingTests run flag set to True, bugs_found set to 2Verify tests_run is True and bugs_found is 2PASS
4Call deploy() to simulate deploymentSince tests_run is True, bugs_found remains 2Verify bugs_found is less than 5PASS
5Assert bugs_found < 5 to confirm early testing effectivenessbugs_found is 2assertLess(2, 5) passesPASS
Failure Scenario
Failing Condition: run_tests_early() is not called before deploy(), so bugs_found remains 5
Execution Trace Quiz - 3 Questions
Test your understanding
What does the test verify about bugs when testing is done early?
AFewer bugs are found compared to late testing
BMore bugs are found compared to late testing
CNo bugs are found at all
DBugs found are the same as late testing
Key Result
Starting testing early in the development process helps catch bugs sooner, reducing the number of bugs found later and improving software quality.

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