翻译工作的开端

  上周五(1.17)工作不是很忙,在浏览几个技术网站的时候发现有个自发的JAVA相关技术翻译团队在招人(无偿的),于是毛遂自荐了一下。周六深夜到家发现人家回复了邮件,给了一小段技术贴让翻译一下,算是面试吧。于是拿出在IBM工作的老本,推敲了二十分钟算是搞定了,之后收到邮件表示通过,然后给了一篇正式文章需要翻译,算是正式开始了我的翻译生涯。

  下面是面试翻译的小段,放出来大家一起探讨下,感觉有的地方自己翻译的还不是很到位。

原文:Parameterized unit tests are used to to test the same code under different conditions. Thanks to parameterized unit tests we can set up a test method that retrieves data from some data source. This data source can be a collection of test data objects, external file or maybe even a database. The general idea is to make it easy to test different conditions with the same unit test method, which will limit the source code we need to write and makes the test code more robust. We can call these tests data-driven unit tests.junit-logo

The best way to achieve data-driven unit tests in JUnit is to use a JUnit’s custom runner �C Parameterized or JUnitParams’ JUnitParamsRunner. Using JUnit’s approach may work in many cases, but the latter seems to be more easy to use and more powerfull.

译文:
单元测试的参数化方式适用于测试不同条件(或业务场景)下的同一段代码。通过单元测试参数化的方式,我们可以创建一个测试方法从数据源中获取一些数据。数据源可以由测试数据对象、外部文件或是数据库组成。整体思路是使用参数化的方式编写一个单元测试的方法,来测试不同条件下被测代码(即源码)的正确性,当然这需要我们提高自身测试代码的健壮性。我们可以使用junit的方式来进行测试数据驱动的管理。
在JUint的单元测试中,实现数据驱动的最好方式是使用一些为JUnit定制的工具―― JUnit 自带的对参数化方法或是一个叫JUnit Parameterized的参数化测试框架。在许多情况下,使用哪种JUnit定制的工具都可以完成我们的工作,但是第二种方法使用起来似乎更为简单和强大。

你可能感兴趣的:(java,单元测试,翻译,Juint)