Bird
Raised Fist0
Testing Fundamentalstesting~15 mins

Testing in the software development lifecycle in Testing Fundamentals - Build an Automation Script

Choose your learning style10 modes available
Verify testing activities in each phase of the software development lifecycle
Preconditions (2)
Step 1: Review the requirements document and identify testable requirements
Step 2: Check that test cases are created based on requirements
Step 3: Verify design documents include testability considerations
Step 4: Confirm unit tests are written and executed during implementation
Step 5: Execute system and integration tests after implementation
Step 6: Validate that defects found during testing are logged and tracked
Step 7: Ensure acceptance testing is performed before deployment
Step 8: Confirm that testing results are documented and reviewed
✅ Expected Result: Testing activities are properly planned and executed in each phase of the software development lifecycle, with test cases linked to requirements, tests executed at appropriate stages, defects tracked, and results documented.
Automation Requirements - Python unittest
Assertions Needed:
Test cases exist for each requirement
Unit tests pass during implementation
Integration and system tests pass
Defects are logged when tests fail
Acceptance tests pass before deployment
Best Practices:
Use clear and descriptive test method names
Organize tests by lifecycle phase
Use setup and teardown methods for test environment preparation
Log test results and failures clearly
Keep tests independent and repeatable
Automated Solution
Testing Fundamentals
import unittest

class TestSDLCPhases(unittest.TestCase):
    def setUp(self):
        # Setup test environment, e.g., load requirements and test cases
        self.requirements = ['Login', 'Search', 'Checkout']
        self.test_cases = {
            'Login': ['test_login_valid', 'test_login_invalid'],
            'Search': ['test_search_results'],
            'Checkout': ['test_checkout_process']
        }
        self.unit_tests_passed = True
        self.integration_tests_passed = True
        self.system_tests_passed = True
        self.defects_logged = []
        self.acceptance_tests_passed = True

    def test_test_cases_exist_for_requirements(self):
        for req in self.requirements:
            self.assertIn(req, self.test_cases, f"No test cases for requirement: {req}")
            self.assertGreater(len(self.test_cases[req]), 0, f"No test cases listed for {req}")

    def test_unit_tests_pass(self):
        self.assertTrue(self.unit_tests_passed, "Unit tests did not pass")

    def test_integration_and_system_tests_pass(self):
        self.assertTrue(self.integration_tests_passed, "Integration tests did not pass")
        self.assertTrue(self.system_tests_passed, "System tests did not pass")

    def test_defects_logged_on_failures(self):
        # Simulate a failure and defect logging
        if not self.unit_tests_passed:
            self.defects_logged.append('Unit test failure defect')
        self.assertTrue(len(self.defects_logged) >= 0, "Defects should be logged when tests fail")

    def test_acceptance_tests_pass_before_deployment(self):
        self.assertTrue(self.acceptance_tests_passed, "Acceptance tests did not pass before deployment")

    def tearDown(self):
        # Clean up test environment
        pass

if __name__ == '__main__':
    unittest.main()

This test class simulates verifying testing activities in the software development lifecycle.

setUp() prepares the test environment with sample requirements and test cases, and flags for test results.

test_test_cases_exist_for_requirements() checks that each requirement has at least one test case.

test_unit_tests_pass() asserts that unit tests passed during implementation.

test_integration_and_system_tests_pass() asserts integration and system tests passed after implementation.

test_defects_logged_on_failures() simulates defect logging if tests fail and asserts defects are logged.

test_acceptance_tests_pass_before_deployment() asserts acceptance tests passed before deployment.

Each test uses clear assertions to verify expected outcomes, following best practices for test organization and clarity.

Common Mistakes - 5 Pitfalls
{'mistake': 'Not linking test cases to specific requirements', 'why_bad': "Without linking, it's unclear if all requirements are tested, risking missed defects.", 'correct_approach': 'Create and verify test cases explicitly mapped to each requirement.'}
Skipping unit tests during implementation
Not logging defects when tests fail
Running acceptance tests after deployment
Writing dependent or non-repeatable tests
Bonus Challenge

Now add data-driven testing with 3 different sets of requirements and test cases

Show Hint

Practice

(1/5)
1. Which phase in the software development lifecycle is primarily responsible for planning how testing will be done?
easy
A. Deployment
B. Coding
C. Requirement Analysis
D. Maintenance

Solution

  1. Step 1: Understand the role of Requirement Analysis

    This phase gathers and analyzes what the software should do, including defining test requirements.
  2. Step 2: Identify testing planning activities

    Planning how to test is done early, during Requirement Analysis, to ensure tests cover all needs.
  3. Final Answer:

    Requirement Analysis -> Option C
  4. Quick Check:

    Testing plan starts in Requirement Analysis [OK]
Hint: Testing plans start with requirements, not coding [OK]
Common Mistakes:
  • Confusing coding phase with testing planning
  • Thinking deployment includes test planning
  • Assuming maintenance is for initial test planning
2. Which of the following is the correct syntax to describe a test case in a test plan document?
easy
A. Test Case ID: TC001\nDescription: Verify login functionality\nExpected Result: User logs in successfully
B. Test Case: Verify login\nResult: Success\nID: 001
C. ID: 001\nTest: Login check\nOutcome: Pass
D. Case Test 1\nCheck login\nExpected: true

Solution

  1. Step 1: Identify standard test case format

    Standard test cases include clear ID, description, and expected result fields.
  2. Step 2: Compare options to standard format

    Test Case ID: TC001\nDescription: Verify login functionality\nExpected Result: User logs in successfully matches the clear, structured format; others are incomplete or unclear.
  3. Final Answer:

    Test Case ID: TC001\nDescription: Verify login functionality\nExpected Result: User logs in successfully -> Option A
  4. Quick Check:

    Clear ID, description, expected result = Test Case ID: TC001\nDescription: Verify login functionality\nExpected Result: User logs in successfully [OK]
Hint: Look for clear ID, description, expected result format [OK]
Common Mistakes:
  • Using unclear or incomplete test case fields
  • Mixing field names or order
  • Omitting expected results
3. Consider this code snippet representing a simple test function in Python:
def test_addition():
    result = 2 + 3
    assert result == 5
    print('Test passed')

What will be the output when this test runs?
medium
A. SyntaxError
B. Test passed
C. No output
D. AssertionError

Solution

  1. Step 1: Analyze the test function logic

    The function adds 2 + 3, stores 5 in result, then asserts result equals 5, which is true.
  2. Step 2: Determine output after assertion

    Since assertion passes, the print statement runs, outputting 'Test passed'.
  3. Final Answer:

    Test passed -> Option B
  4. Quick Check:

    Assertion true means print runs [OK]
Hint: If assert condition is true, print runs [OK]
Common Mistakes:
  • Thinking assertion always raises error
  • Expecting no output from print
  • Confusing syntax with runtime error
4. A tester wrote this test script snippet:
def test_divide():
    result = 10 / 0
    assert result == 0

What is the main problem with this test?
medium
A. Test function name is incorrect
B. Assertion should check for 10, not 0
C. Missing print statement
D. Division by zero causes runtime error

Solution

  1. Step 1: Identify the operation causing error

    Dividing 10 by 0 causes a ZeroDivisionError at runtime.
  2. Step 2: Understand impact on test execution

    Because of the error, assertion is never reached and test fails with exception.
  3. Final Answer:

    Division by zero causes runtime error -> Option D
  4. Quick Check:

    Division by zero = runtime error [OK]
Hint: Division by zero always causes error [OK]
Common Mistakes:
  • Ignoring runtime error and focusing on assertion
  • Thinking assertion is wrong instead
  • Assuming print statement needed
5. In a software project, testing is integrated throughout the lifecycle. Which testing type is best suited to catch issues caused by changes in code after deployment?
hard
A. Regression Testing
B. Unit Testing
C. Acceptance Testing
D. Smoke Testing

Solution

  1. Step 1: Understand testing types and their purpose

    Unit Testing checks small code parts; Acceptance Testing checks user needs; Smoke Testing checks basic functionality.
  2. Step 2: Identify testing for post-deployment changes

    Regression Testing reruns tests to ensure new changes don't break existing features after deployment.
  3. Final Answer:

    Regression Testing -> Option A
  4. Quick Check:

    Regression Testing catches post-change issues [OK]
Hint: Regression Testing checks after code changes [OK]
Common Mistakes:
  • Confusing unit testing with regression testing
  • Thinking acceptance testing covers code changes
  • Assuming smoke testing is for detailed checks
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