Java – how to test code written for AWS API

I am writing an application in Java to upload a file to AWS S3 The file will be provided to the application in the form of parameters rather than hard coding I want to write a test to ensure that the file is actually uploaded to S3 The test will be written before TDD code (I've actually written the code, but I want to make TDD a habit)

What should I do? I'll use JUnit because it's the one I'm most familiar with

Thank you in advance for any help

Solution

Actual uploads and tests are part of your integration tests, not unit tests If you wrap S3 API in a very thin class, you will simulate the business class of this class for unit test, and you will use the real implementation for integration test

The actual exploratory test (learning and verification) how and how Amazon S3 works is what you actually do in a separate experimental setup

PS: I don't recommend using Amazon S3 interface directly in your business course, but wrap it in your concise interface so that if you decide to change "back-end storage", you can easily change it

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>