songining

- ν…ŒμŠ€νŠΈλŠ” λ”°λ‘œ application.yml μ„€μ •νŒŒμΌ λ§Œλ“€μ–΄μ£ΌλŠ” 것이 μ’‹μŒ 

-각 ν…ŒμŠ€νŠΈ ν•¨μˆ˜μ—λŠ” @Test μ–΄λ…Έν…Œμ΄μ…˜μ„ 뢙이며 λ§Œμ•½ μ˜ˆμ™Έκ°€ λ°œμƒν•˜λŠ”μ§€ ν™•μΈν•˜κ³  싢은 κ²½μš°μ—λŠ”

@Test(expected = IllegalStateException.class)

와 같이 ν•΄λ‹Ή μ˜ˆμ™Έμ— λŒ€ν•œ μ–΄λ…Έν…Œμ΄μ…˜μ„ λ§Œλ“€μ–΄μ€€λ‹€. 

- ν…ŒμŠ€νŠΈ μ½”λ“œ ν‹€ μ˜ˆμ‹œ

@RunWith(SpringRunner.class)
@SpringBootTest
@Transactional // ν…ŒμŠ€νŠΈ λλ‚ λ•Œ λ‹€μ‹œ rollback 해버림
public class MemberServiceTest {

    @Autowired MemberService memberService;
    @Autowired MemberRepository memberRepository;
    
    @Test
    public void ~test() throws Exception{
    .
    .
    }
    
 }

- λ‹¨μœ„ ν…ŒμŠ€νŠΈ

@DataJpaTest의 경우 default둜 entity와 spring data jpa repositoryλ₯Ό μŠ€μΊ”ν•œλ‹€.

(spring data jpa respositoryκ°€ μ•„λ‹ˆλ©΄ μ£Όμž…μ΄ μ•ˆλœλ‹€***)

 

-톡합 ν…ŒμŠ€νŠΈ 

@SpringBootTestλŠ” λ‹¨μœ„ν…ŒμŠ€νŠΈκ°™μ€ κΈ°λŠ₯ 검증이 μ•„λ‹Œ λͺ¨λ“  λΉˆμ„ μŠ€μΊ”ν•΄μ„œ λ‘œλ“œν•˜λŠ” ν†΅ν•©ν…ŒμŠ€νŠΈμ—μ„œ μ‚¬μš©λœλ‹€.