Writing standards for unit testing

前端 未结 10 928
自闭症患者
自闭症患者 2021-01-31 12:05

I plan to introduce a set of standards for writing unit tests into my team. But what to include?

These two posts (Unit test naming best practices and Best practices for

10条回答
  •  鱼传尺愫
    2021-01-31 12:53

    Users of full-featured IDE's will find that "some of them" have quite detailed support for creating tests in a specific pattern. Given this class:

    public class MyService {
        public String method1(){
            return "";
        }
    
        public void method2(){
    
        }
    
        public void method3HasAlongName(){
    
        }
    }
    

    When I press ctrl-shift-T in intellij IDEA I get this test class after answering 1 dialog box:

    public class MyServiceTest {
        @Test
        public void testMethod1() {
            // Add your code here
        }
    
        @Test
        public void testMethod2() {
            // Add your code here
        }
    
        @Test
        public void testMethod3HasAlongName() {
            // Add your code here
        }
    }
    

    So you may want to take a close look at tool support before writing your standards.

提交回复
热议问题