2021-05-28(Fri)

Facts (์‚ฌ์‹ค, ๊ฐ๊ด€)

  • ์ฝ”๋“œ์ˆจ 4์ฃผ์ฐจ ๊ณผ์ œ๋ฅผ ์ง„ํ–‰ํ–ˆ๋‹ค.

  • ๋ฉด์ ‘ ๋•Œ ๋‹ตํ•˜์ง€ ๋ชป ํ–ˆ๊ฑฐ๋‚˜ ์—‰๋šฑํ•˜๊ฒŒ ๋‹ตํ–ˆ๋˜ ๊ฒƒ๋“ค์„ ๋ณต๊ธฐํ–ˆ๋‹ค.

Feelings (๋Š๋‚Œ, ์ฃผ๊ด€)

  • ๊ณผ์ œ๋ฅผ 9์‹œ ์ „์— ๋”ฑ ๋งˆ์น˜๊ณ  ์‹ถ๋‹ค. ์•„์ง๋„ ์™„์„ฑ์„ ๋ชป ํ•˜๋‹ค๋‹ˆ.. ์•„์ง mockito๊ฐ€ ์ต์ˆ™์น˜ ์•Š์€ ํƒ“์ด๋‹ค. ๋‚ด์ผ์€ ๊ผญ ํ•ด๋ด์•ผ๊ฒ ๋‹ค.

  • ๋ฉด์ ‘ ๋•Œ ์—‰๋šฑํ•˜๊ฒŒ ๋‹ตํ–ˆ๋˜ ๋ถ€๋ถ„๋“ค์ด ๋ถ€๋„๋Ÿฝ๋‹ค.. ์–ด์„œ ์ฑ„์›Œ๋„ฃ์ž!

  • ์ด๋ ‡๊ฒŒ ํ•™์Šตํ•  ์ˆ˜ ์žˆ๋‹ค๋Š” ๊ฒƒ์ด ํ–‰๋ณตํ•˜๊ณ  ๊ฐ์‚ฌํ•˜๋‹ค.

Findings (๋ฐฐ์šด ์ )

์‹ ์ž…์‚ฌ์›์„ ์œ„ํ•œ ์›น์„œ๋น„์Šค ํ™•์žฅ ์ „๋žต

ํฌ์ธํŠธ๋Š” ํ•œ ๊ณณ์˜ ์žฅ์• ๊ฐ€ ๋‹ค๋ฅธ ๊ณณ์œผ๋กœ ํผ์ง€์ง€ ์•Š๋„๋ก ๊ฒฉ๋ฆฌ์‹œํ‚ค๊ณ , ๋ถ€ํ•˜๋ฅผ ๊ฐ๋‹นํ•  ์ˆ˜ ์žˆ๋„๋ก ๋‚˜๋ˆ„๋Š” ๊ฒƒ์ด ํ•ต์‹ฌ์ด๋„ค. ํ‚ค๋„ ์ „๋žต์— ๋”ฐ๋ผ ์„ค๊ณ„๊ฐ€ ๋‹ฌ๋ผ์ ธ์•ผ ํ•œ๋‹ค.

์ฐธ๊ณ 

https://www.slideshare.net/charsyam2/webservice-scaling-for-newbie

Mockito

doThrow ํ™œ์šฉ๋ฒ•์„ ์•Œ๊ฒŒ ๋˜์—ˆ๋‹ค. https://www.baeldung.com/mockito-exceptions

given(productService.updateProduct(givenId, any(Product.class)))
                            .will(invocation -> invocation.getArgument(1));

์œ„ ์ฒ˜๋Ÿผ ์ ์—ˆ๋”๋‹ˆ ์•„๋ž˜ ์—๋Ÿฌ ๋ฉ”์„ธ์ง€๊ฐ€ ๋‚˜์™”๋‹ค.

๋„˜๋‚˜ ์นœ์ ˆํ•˜๋‹ค. eq๋ฅผ ๋ถ™์—ฌ์„œ matcher ํ˜•์‹์— ๋งž์ถฐ์ฃผ์ž.

given(productService.updateProduct(eq(givenId), any(Product.class)))
                            .will(invocation -> invocation.getArgument(1));

Affimation (์ž๊ธฐ ์„ ์–ธ)

  • ๋‚˜๋Š” ์‹œ๊ฐ„ ๊ด€๋ฆฌ๋ฅผ ์น˜๋ฐ€ํ•˜๊ฒŒ ํ•˜๋Š” ๊ฐœ๋ฐœ์ž๋‹ค.

Last updated