1. 테스트 코드 네이밍 룰

1.1 안좋은 테스트 네이밍

Bad : testCalculateSalary

why?→ 테스트가 실패시 알 수 있는 정보가 없다.

1.2 테스트 네이밍의 3가지 요소

→ 예) test_methodName_withCertainState_shouldDoSomething


testGetToken

testCanNotGetToken

testShowSuccess

testShowFailWrongPassword

testStoreSuccess

testSetStoreDataSuccess

testStoreFailEmptyData

testShowWithDtoShouldReturnToken

testShowWithWrongDtoShouldReturnNull

testShowApiWithLoginDataShouldReturnToken

testShowApiWithWrongPasswordShouldReturn401

testRepoStoreWithDtoShouldSameEmail

testSetStoreDataWihhDtoShouldEqualEmail

testUseCaseStoreWithDtoShouldThrowUseCaseException

→ 이정도로 정리하고 나니까 should return이란 말이 매우 신경쓰이기 시작.

2. GWT(Given When Then)

bliki: GivenWhenThen

Feature: User trades stocks
  Scenario: User requests a sell before close of trading
    Given I have 100 shares of MSFT stock
       And I have 150 shares of APPL stock
       And the time is before close of trading

    When I ask to sell 20 shares of MSFT stock
     
     Then I should have 80 shares of MSFT stock
      And I should have 150 shares of APPL stock
      And a sell order for 20 shares of MSFT stock should have been executed

Using Given/When/Then For Tests

2. 테스트 스텁이란?