一枚程序员眼中的单元测试(4)

发表于:2017-09-11来源:袁慎建作者:袁慎建点击数: 标签:单元测试
StringUtilsTest { @Test void convert_to_upper_case () throws Exception { assertThat ( StringUtils . toUpperCase ( unit-test ), is ( UNIT-TEST )); } } 这一 小段 测试代码所做的事情是在 验证
StringUtilsTest { @Test void convert_to_upper_case() throws Exception { assertThat(StringUtils.toUpperCase("unit-test"), is("UNIT-TEST")); } }

这一小段测试代码所做的事情是在验证StringUtils#toUpperCase方法的功能正确性。

顺便用一句话来形容单元测试

开发人员编写一小段代码,用于检验被检测代码的一个很小的、很明确的功能是否正确。

原文转自:http://sjyuan.cc/unit-test-view-from-a-programmer/

...