How do you test code written against AWS API

The actual uploading and the tests that are doing it are part of your integration testing, not the unit testing. If you wrap the S3 API in a very thin class, you will mock that class for unit testing of your business classes, and you will use the real implementation for integration testing.
If you have decided, your business classes to take directly the AmazonS3 interface, then for unit testing you have to mock that one.

The actual exploratory testing (learning and verifying) if and how amazon s3 works is what you actually do in separate experimental setup.

P.S. I do not recommend using the AmazonS3 interface directly in your business classes, rather, wrap it in a thin interface of yours, so that if you decide to change the 'back-end storage' you can easily change it.


I'm not a Java programmer but you probably want to look into mocking. There is a SoapUI tool called MockService that appears to allow mocking of an external service like those provided by AWS.


Op De Cirkel answer is good in unit testing scope but if you are writing framework support or simply need to run the AWS S3 calls during your tests, you can run any service that offer AWS compatible APIs. OpenStack is one of them and can be run in a virtual machine (see DevStack).

Or you can choose from a variety of test-oriented tools that provide AWS compatible APIs.

Here are some that expose S3 service:

  • S3Ninja (actually written in Java)
  • FakeS3 (ruby)
  • s3mock (Scala with Java API)