Unit testing is when you write test code to verify 单元测试就是在编程时用测试代码来验证代码中的各个单元
1.AAA逻辑顺序 arrange act assert [after(close something)]
@Test public void testSay() { // Arrange HelloWorld helloWorld = new HelloWorld(); // Act String result = helloWorld.say(); // Assert assertEquals("Hello World!", result); } // After (optional) @After public void tearDown() { // Close something... }
2.Given When Then描述结构 (given someContext when DoingSomeBehavior Then SomeResultOccurs)
3.some_result_occurs_when_doing….
4.测试即文档
5.Suite-Fixture-Case
6.无限接近言简意赅的自然化语言
7.Matcher神器- Hamcrest
原文转自:http://xueqian.github.io/2016/01/10/单元测试基本概念/