你怎么测试code写的对AWS API [英] How do you test code written against AWS API

查看:82
本文介绍了你怎么测试code写的对AWS API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用Java编写的应用程序了将文件上传到AWS S3。该文件将在一个参数,而不是硬$ C $光盘给予该应用程序。我想编写测试,以确保文件实际上被上传到S3。测试将前的code对于TDD被写入。 (其实我也已经写了code,但我想根深蒂固TDD实践到我所有的作为一种习惯的工作)

I'm writing an application in Java that will upload a file up to AWS S3. The file will be given to the application in an argument, not hardcoded. I'd like to write tests to ensure that the file actually gets uploaded to S3. The test will be written before the code for TDD. (I have actually already written the code, but I'd like to ingrain TDD practices into all of my work as a habit)

究竟如何,我会去这样做?我将使用JUnit因为这是我最熟悉的。

How exactly would I go about doing this? I will be using JUnit as that's what I'm most familiar with.

在此先感谢您的帮助。

推荐答案

实际的上传和正在做的测试是你的集成测试的一部分,而不是的单元测试。如果包装在一个非常薄的类S3 API,你会嘲笑这个类为您的企业类的单元测试,你将使用真正实现集成测试。
如果你已经决定,你的企业的课程采取直接的 AmazonS3接口的,那么对于单元测试你有嘲笑的那一个。

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.

在实际的的探索性测试的(学习和验证)是否以及如何Amazon S3的工作原理是,你实际上是在做不同的实验设置的东西。

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

P.S。我不建议直接在你的业务类使用AmazonS3接口,而是把它包在薄薄的你的接口,这样,如果你决定改变'后端存储',你可以轻松地改变它。

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.

这篇关于你怎么测试code写的对AWS API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆