Should I change the naming convention for my unit tests?

后端 未结 7 2480
死守一世寂寞
死守一世寂寞 2021-02-20 04:45

I currently use a simple convention for my unit tests. If I have a class named \"EmployeeReader\", I create a test class named \"EmployeeReader.Tests. I then create all the test

7条回答
  •  走了就别回头了
    2021-02-20 05:22

    The naming convention I've been using is:

    functionName_shouldDoThis_whenThisIsTheSituation

    For example, these would be some test names for a stack's 'pop' function

    pop_shouldThrowEmptyStackException_whenTheStackIsEmpty

    pop_shouldReturnTheObjectOnTheTopOfTheStack_whenThereIsAnObjectOnTheStack

提交回复
热议问题