Skip to content

tdd mock test - #13

Open
dseoki wants to merge 2 commits into
mainfrom
feature/tdd-first
Open

tdd mock test#13
dseoki wants to merge 2 commits into
mainfrom
feature/tdd-first

Conversation

@dseoki

@dseoki dseoki commented Apr 23, 2024

Copy link
Copy Markdown
Collaborator

No description provided.

public void searchHikingTest() {
Hiking hiking1 = new Hiking();
hiking1.setId(1L);
hiking1.setHikeStartDate(LocalDateTime.of(2024, 2, 15, 9, 00));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

반복되어 사용되는 LocalDateTime.of(2024, 2, 15, 9, 00)와 같은 값은 상수로 처리하시면 좋을 것 같습니다.

verify(repository, times(1)).save(any(Hiking.class));
}

// @Test

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

주석처리된 코드는 지워주시는게 좋습니다.

import static org.mockito.Mockito.*;

@SpringBootTest
public class HikingServiceTest {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mock repository에서 예외를 발생시키는 테스트를 추가하시면 좋습니다.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants