DVA-C02 exam dumps

DVA-C02 practice question 274 of 399

AWS Certified Developer - Associate. Associate level, Amazon Web Services. Free question with the correct answer and a full explanation.

DVA-C02 Question 274

Single answer

You are developing an AWS Lambda function that interacts with an Amazon DynamoDB table to store user information. To ensure code quality, you want to automate unit tests for your function without making actual calls to DynamoDB. Which approach should you take?

  1. A

    Write unit tests that directly interact with the DynamoDB table in your AWS account to validate the function's behavior.

  2. B

    Use a mocking library like AWS SDK Mock to simulate DynamoDB API calls in your unit tests.

  3. C

    Configure an Amazon DynamoDB local instance and use it for all unit tests.

  4. D

    Rely on manual testing in the AWS Management Console instead of writing automated tests.

Show answer and explanation

Correct answer: B

Explanation

The correct answer is to use a mocking library like AWS SDK Mock to simulate DynamoDB API calls in your unit tests. Unit testing focuses on testing code in isolation, without dependencies on external resources like DynamoDB. Mocking ensures that tests are fast and reliable while verifying the logic of your function.

  • A. Incorrect.

    Directly interacting with the DynamoDB table in your AWS account for unit tests is not recommended because it introduces external dependencies, making the test less isolated and slower.

  • B. Correct.

    Using a mocking library like AWS SDK Mock is the correct approach because it allows you to simulate DynamoDB API calls, ensuring your unit tests are fast, isolated, and do not depend on actual AWS resources.

  • C. Incorrect.

    Using a DynamoDB local instance is more suited for integration testing rather than unit testing, as it still involves external configuration and dependencies.

  • D. Incorrect.

    Relying on manual testing is not recommended because it is time-consuming, error-prone, and goes against the principles of automated software testing.

Timed practice exam

Take a DVA-C02 practice test under exam conditions

65 questions in 130 minutes, drawn from this bank, with a score report and a per-question review when you finish.

Start timed exam