Questions#

Theory: White Box vs Black Box Testing#

  1. What is the fundamental difference between White Box and Black Box testing?

    • Hint: Think about what the tester can see regarding the internal code.

  2. List the three basic steps to perform White Box testing.

    • Hint: It starts with understanding something specific.

  3. What are two advantages of Black Box testing?

    • Hint: Consider the tester’s perspective and the implementation details.

  4. Compare White Box and Black Box testing in terms of “Module Communication”.

    • Hint: Which one facilitates verifying how modules talk to each other?

  5. Why is Unit Testing considered a “White Box” technique?

    • Hint: Who writes unit tests and what do they inspect?

Practice: Pytest#

  1. How does pytest automatically discover test files and functions?

    • Hint: What naming convention must be followed?

  2. What is the purpose of a fixture in pytest? Give an example of when you would use one.

    • Hint: Think about setup code and reusability.

  3. How do you assert that a specific exception is raised in a test function?

    • Hint: Look for a specific context manager provided by pytest.

  4. What is “Mocking” and why is it useful when testing database interactions?

    • Hint: Consider what happens if the database is down or slow.

  5. In the directory structure, why are __init__.py files included in src and tests directories?

    • Hint: How does Python handle modules?