CI/CD Testing: Unit, Integration, and End-to-End Fundamentals Quiz

Explore essential concepts of testing in CI/CD pipelines, focusing on understanding unit, integration, and end-to-end tests. Evaluate your grasp of test types, their purposes, scopes, and common scenarios in software development workflows.

  1. Identify Unit Testing

    Which type of test is focused on checking a single function or component in isolation from the rest of the system?

    1. End-to-end test
    2. Unit test
    3. Acceptance test
    4. Integration test

    Explanation: A unit test verifies the behavior of a single function, method, or component without depending on other parts of the system. Integration tests involve combining components to test their interactions, which covers more than isolated units. End-to-end tests simulate real user flows through the entire application. Acceptance tests check compliance with business requirements but might span multiple components.

  2. Purpose of Integration Testing

    What is the main goal of an integration test in a CI/CD context?

    1. To validate individual code statements
    2. To simulate real user scenarios from start to finish
    3. To assess the interaction of combined components or modules
    4. To measure deployment speed

    Explanation: Integration tests are designed to verify that different components or modules work together as intended. They do not focus on individual code statements; that's the role of unit tests. End-to-end tests are used for simulating complete real-world scenarios, not just interactions. Deployment speed measurement is unrelated to testing types.

  3. End-to-End Test Example

    A test scenario fills out a registration form on a website and then verifies the creation of a user account in the system. What type of test is this?

    1. Unit test
    2. End-to-end test
    3. Performance test
    4. Smoke test

    Explanation: End-to-end tests simulate a user's journey through the entire application, such as registering and checking account creation. Smoke tests are basic checks to see if an application launches or main features work, not full workflows. Unit tests only examine small units of code, not full flows. Performance tests measure responsiveness and speed, rather than correctness of user journeys.

  4. When to Use Unit Tests

    In a CI/CD pipeline, at which stage are unit tests typically run to provide the fastest feedback on new changes?

    1. After full deployment to production
    2. After running end-to-end tests
    3. Only during manual code reviews
    4. Before committing code changes

    Explanation: Unit tests are usually executed early, often before code changes are integrated, to quickly identify issues with small units of code. Running unit tests after deploying to production would delay detection of bugs. Manual code reviews are for human inspection, not automated tests. Typically, end-to-end tests are run after unit tests, not before.

  5. Isolation in Unit Testing

    Why should unit tests avoid relying on external systems like databases or APIs?

    1. To ensure tests only verify the unit being tested
    2. To guarantee faster automated deployments
    3. To reduce system resources
    4. To check integration between services

    Explanation: Unit tests are meant to test isolated pieces of code, helping quickly locate bugs. If they rely on external systems, they risk introducing unrelated failures. Reducing resource usage and speeding up deployments are secondary benefits but not the primary purpose. Checking integration is handled by integration tests, not unit tests.

  6. Integration Test Scenario

    Suppose you write a test to confirm that a user profile can be created only after user authentication succeeds. What type of test is this?

    1. UI test
    2. Unit test
    3. Integration test
    4. Configuration test

    Explanation: This test checks the interaction between authentication and profile creation modules, making it an integration test. Configuration tests check system settings, not feature interactions. Unit tests only examine a single function in isolation. UI tests focus on the appearance and functionality of the user interface, not necessarily the interaction of backend modules.

  7. Scope of End-to-End Testing

    Which of the following best describes the purpose of end-to-end testing?

    1. Ensuring every code variable is correct
    2. Automatically fixing merge conflicts
    3. Testing only the database layer
    4. Validating full application workflows from the user's perspective

    Explanation: End-to-end tests check how all parts of the application function together in real user scenarios. They are not concerned with individual code variables, which is the job of unit tests. Testing only the database layer is too narrow and is covered by integration or unit tests. Resolving merge conflicts is a version control task, not related to testing.

  8. Test Pyramids in CI/CD

    Within a CI/CD testing pyramid, which type of test should generally have the largest number of cases?

    1. Smoke tests
    2. Integration tests
    3. Unit tests
    4. End-to-end tests

    Explanation: The testing pyramid suggests having many unit tests, fewer integration tests, and the least end-to-end tests, as unit tests are fast and granular. Integration and end-to-end tests are more complex, slower, and should be fewer. Smoke tests are a minimal set run for basic application checks, not intended for large quantities.

  9. Identifying Flaky Tests

    A test sometimes passes and sometimes fails under the same conditions, often due to timing issues or external dependencies. What is this test called?

    1. Silent test
    2. Flaky test
    3. Flat test
    4. Static test

    Explanation: A flaky test is inconsistent, often failing due to external factors rather than errors in the code being tested. 'Silent test' and 'flat test' are not recognized terms in testing, and 'static test' usually refers to analysis without execution, not flaky behavior.

  10. Test Automation in CI/CD

    What is a primary benefit of automating unit, integration, and end-to-end tests in a CI/CD process?

    1. Automatically generates documentation
    2. Eliminates the need for code reviews
    3. Enables fast and reliable feedback on code changes
    4. Guarantees zero production issues

    Explanation: Automating tests provides rapid feedback, improving code quality and deployment confidence. Test automation does not automatically generate documentation or replace the value of code reviews. While it reduces risk, it cannot guarantee that no production issues will ever occur.