0920 - 0926


# 0920 - 0926

# 0921 - org.assertj.core.api.Assertions.assertThat

# assertj๋ž€?

ํ…Œ์ŠคํŠธ ์ฝ”๋“œ ์ž‘์„ฑ์„ ์‰ฝ๊ฒŒ ๋„์™€์ฃผ๋Š” ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ
๋ฉ”์†Œ๋“œ ์ฒด์ด๋‹ ์ง€์› (๋ฉ”์„œ๋“œ ์ฒด์ด๋‹์ด๋ž€ ์—ฌ๋Ÿฌ ๋ฉ”์„œ๋“œ ํ˜ธ์ถœ์„ ์—ฐ๊ฒฐํ•ด ํ•˜๋‚˜์˜ ์‹คํ–‰๋ฌธ์œผ๋กœ ํ‘œํ˜„ํ•˜๋Š” ๋ฌธ)

# asertj ์‚ฌ์šฉํ•˜๊ธฐ

# ์˜์กด์„ฑ

  • maven
<dependency>
  <groupId>org.assertj</groupId>
  <artifactId>assertj-core</artifactId>
  <!-- use 2.9.1 for Java 7 projects -->
  <version>3.11.1</version>
  <scope>test</scope>
</dependency>
  • gradle
testCompile("org.assertj:assertj-core:3.11.1")

# ์„ ์–ธ

import static org.assertj.core.api.Assertions.assertThat;

# ์‚ฌ์šฉ๋ฒ•

  • isEqualTo() -> ์ฃผ์†Œ๊ฐ’์ด ์•„๋‹ˆ๋‹ค.
@Test
public void eq(){
    String name ="์ด๋ฆ„";
    assertThat(name).isEqualTo("์ด๋ฆ„"); // success
}
  • ๋ฆฌ์ŠคํŠธ ํ•„๋“œ๊ฐ’ ๊ฒ€์ฆ
  • extraction('์†์„ฑ๋ช…').containsExactly('ํ•„๋“œ๊ฐ’1', 'ํ•„๋“œ๊ฐ’2', 'ํ•„๋“œ๊ฐ’3')
@Test
public void list(){
    User user1 = new User("ํ”ผ์นด์ธ„");
    User user2 = new User("ํŒŒ์ด๋ฆฌ");
    User user3 = new User("๊ผฌ๋ถ€๊ธฐ");

    List<User> list = new ArrayList<>();
    list.add(user1);
    list.add(user2);
    list.add(user3);

    assertThat(list).extracting("name")
            .containsExactly("ํ”ผ์นด์ธ„","ํŒŒ์ด๋ฆฌ","๊ผฌ๋ถ€๊ธฐ");//success
    
    assertThat(list).extracting("name")
            .containsExactly("ํ”ผ์นด์ธ„"); //fail
}
  • ์˜ค๋ธŒ์ ํŠธ ๊ฐ์ฒด ๊ฒ€์ฆ
  • ๊ฐ์ฒด์— hashCode(), equals() ๊ตฌํ˜„
@Test
public void objectValue(){
    assertThat(ํ”ผ์นด์ธ„User).contains(new User("ํ”ผ์นด์ธ„"));
}
  • ์˜ˆ์™ธ ํ…Œ์ŠคํŠธ
@ParameterizedTest
@ValueSource(strings = {"", "spring"})
@DisplayName("์ด๋ฆ„ ๊ธธ์ด๊ฐ€ 0 ์ดํ•˜ ๋˜๋Š” 5 ์ด์ƒ์ผ ๋•Œ ์—๋Ÿฌ ํ™•์ธ")
void car_name_exception(String name) {
  assertThatThrownBy(() -> new Car(name))
      .isInstanceOf(IllegalStateException.class)
      .hasMessageContaining("์ด๋ฆ„ ๊ธธ์ด๋Š” 0์ดํ•˜ ๋˜๋Š” 5์ด์ƒ์ด์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.");
}

# 0922 - git flow

# git-flow๋ž€

git์œผ๋กœ ๊ฐœ๋ฐœํ•  ๋•Œ ๊ฑฐ์˜ ํ‘œ์ค€๊ณผ ๊ฐ™์ด ์‚ฌ์šฉ๋˜๋Š” ๋ฐฉ๋ฒ•๋ก 
๊ฐ์ž ๊ฐœ๋ฐœ ํ™˜๊ฒฝ์— ๋”ฐ๋ผ ์ˆ˜์ •ํ•˜๊ณ  ๋ณ€ํ˜•ํ•ด์„œ ์‚ฌ์šฉ

# git-flow ์ „๋žต

  • master : ์ œํ’ˆ์œผ๋กœ ์ถœ์‹œ ๋  ์ˆ˜ ์žˆ๋Š” ๋ธŒ๋žœ์น˜
  • develop : ๋‹ค์Œ ์ถœ์‹œ ๋ฒ„์ „์„ ๊ฐœ๋ฐœํ•˜๋Š” ๋ธŒ๋žœ์น˜
  • feature : ๊ธฐ๋Šฅ์„ ๊ฐœ๋ฐœํ•˜๋Š” ๋ธŒ๋žœ์น˜
  • release : ์ด๋ฒˆ ์ถœ์‹œ ๋ฒ„์ „์„ ์ค€๋น„ํ•˜๋Š” ๋ธŒ๋žœ์น˜
  • hotfix : ์ถœ์‹œ ๋ฒ„์ „์—์„œ ๋ฐœ์ƒํ•œ ๋ฒ„๊ทธ๋ฅผ ์ˆ˜์ •ํ•˜๋Š” ๋ธŒ๋žœ์น˜

# 0924 - Merge, Squash and Merger, Rebase and Merge

Github์˜ ์ƒˆ๋ฒ„์ „์—์„œ merge, squash and merge, rebse and merge ์„ธ ์ข…๋ฅ˜์˜ merge๋ฅผ ๋ชจ๋‘ ์ง€์›ํ•˜๊ธฐ ์‹œ์ž‘ํ–ˆ๋‹ค. ๊ฐ ๋จธ์ง€ ๋ฐฉ์‹์— ๋”ฐ๋ผ ์ปค๋ฐ‹ ํžˆ์Šคํ† ๋ฆฌ๊ฐ€ ๋‹ฌ๋ผ์ง€๊ธฐ ๋–„๋ฌธ์— ์–ด๋–ค ๊ฒฝ์šฐ์— ์–ด๋–ค ๋จธ์ง€๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ์ด ์ข‹์€์ง€ ํ™•์ธ.

# Merge

  • a, b, c๋ฅผ refer ํ•˜๋Š” m ์ปค๋ฐ‹ ๋…ธ๋“œ ์ƒ์„ฑ, m์€ parent๋กœ init, c๋ฅผ ๊ฐ€์ง
  • ์ปค๋ฐ‹ m์—์„œ๋ถ€ํ„ฐ ๋’ค๋กœ ๋˜๋Œ์•„๊ฐ€๋ฉด์„œ ๋ถ€๋ชจ๋ฅผ ๋ชจ๋‘ ์ฐพ์•„ ๋ธŒ๋ Œ์น˜๋ฅผ ๊ตฌ์„ฑ. ์ปค๋ฐ‹ m์€ ๋ถ€๋ชจ๋กœ c, Init์„ ๊ฐ€์ง€๊ณ  ์žˆ์œผ๋ฉฐ, c๋Š” b๋ฅผ, b๋Š” a๋ฅผ, a๋Š” Init์„ ๋‹ค์‹œ ๋ถ€๋ชจ๋กœ ๊ฐ€์ง, ์ด ํ˜•์ƒ์„ ๋ชจ๋‘ backtrace ํ•˜์—ฌ, Init->a->b->c->m์ด๋ผ๋Š” ๊ตฌ์กฐ๋ฅผ ๋งŒ๋“ค๊ณ  ์ด ๊ตฌ์กฐ๊ฐ€ ๋ชจ๋‘ ํžˆ์Šคํ† ๋ฆฌ์— ๋‚จ์Œ.
  • htfix - develop, hotfix - master ๋ธŒ๋ Œ์น˜๊ฐ„์˜ ๋จธ์ง€์— ์œ ์šฉ

# Squash and Merge

  • a, b, c๋ฅผ ํ•ฉ์ณ์„œ ์ƒˆ๋กœ์šด ์ปค๋ฐ‹์œผ๋กœ ๋งŒ๋“ค๊ณ , ๋จธ์ง€ ๋Œ€์ƒ ๋ธŒ๋ Œ์น˜์— ์ถ”๊ฐ€, 'a,b,c'์ปค๋ฐ‹์€ parent๋ฅผ Init ํ•˜๋‚˜๋งŒ ๊ฐ€์ง
  • ์ปค๋ฐ‹ 'a,b,c'๋Š” Init๋งŒ์„ ๋ถ€๋ชจ๋กœ ๊ฐ€์ง„ ๋‹จ์ผ ์ปค๋ฐ‹. ์ž‘์—…ํ–ˆ๋˜ ๋ธŒ๋ Œ์น˜์˜ a, b, c์ปค๋ฐ‹๋“ค์€ ๋จธ์ง€ ํ›„์˜ ๋ฉ”์ธ ๋ธŒ๋ Œ์น˜ ์ปค๋ฐ‹ Init, 'a,b,c'์™€ ์•„๋ฌด๋Ÿฐ ์—ฐ๊ด€์„ ๊ฐ€์ง€์ง€ ์•Š์Œ.
  • develop - feature, htfix - develop, hotfix - master ๋ธŒ๋ Œ์น˜๊ฐ„์˜ ๋จธ์ง€์— ์œ ์šฉ

# Rebase and Merge

  • a, b, c ๋ฅผ ์‹ฌ๋ฆฌ์Šค(Seamless ๋Š” Seam (๊ฒน์นœ๋ถ€๋ถ„)์ด less (์—†๋Š”) ๊ฒƒ)ํ•˜๊ฒŒ ๋จธ์ง€ ๋Œ€์ƒ ๋ธŒ๋ Œ์น˜๋กœ ์ถ”๊ฐ€, ๊ฐ ์ปค๋ฐ‹๋“ค์€ ๋ชจ๋‘ parent๋ฅผ ํ•˜๋‚˜์”ฉ๋งŒ ๊ฐ€์ง.
  • ์ปค๋ฐ‹ a, b, c์˜ ๊ด€๊ณ„๋ฅผ ๊ทธ๋Œ€๋กœ ์œ ์ง€ํ•œ ์ฑ„, ๋ฉ”์ธ ๋ธŒ๋ Œ์น˜์— ๊ทธ๋Œ€๋กœ ์ถ”๊ฐ€. ์ปค๋ฐ‹ a๋Š” ๋ถ€๋ชจ๋กœ ์ปค๋ฐ‹ e๋ฅผ ๊ฐ€์ง. Rebase and Merge ์ž‘์—… ํ›„์—๋Š”, ์ž‘์—…ํ–ˆ๋˜ ๋ธŒ๋ Œ์น˜์˜ a, b, c์ปค๋ฐ‹๋“ค์€ ๋จธ์ง€ ํ›„์˜ ๋ฉ”์ธ ๋ธŒ๋ Œ์น˜์˜ Init, d, e, a, b, c ์ปค๋ฐ‹๋“ค๊ณผ ์—ฐ๊ด€ ๊ด€๊ณ„๋ฅผ ๊ฐ€์ง€์ง€ ์•Š์Œ.
  • master - develop ๋ธŒ๋ Œ์น˜๊ฐ„์˜ ๋จธ์ง€์— ์œ ์šฉ

# 0925 - ํ”„๋ ˆ์ž„์›Œํฌ๊ณผ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ

# framework(ํ”„๋ ˆ์ž„์›Œํฌ)

ํ”„๋ ˆ์ž„์›Œํฌ๋Š” ๋ผˆ๋Œ€๋‚˜ ๊ธฐ๋ฐ˜๊ตฌ์กฐ๋ฅผ ๋œปํ•˜๋Š”๋ฐ, Application ๊ฐœ๋ฐœ ์‹œ ํ•„์ˆ˜์ ์ธ ์ฝ”๋“œ, ์•Œ๊ณ ๋ฆฌ์ฆ˜, ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ์—ฐ๋™ ๋“ฑ๊ณผ ๊ฐ™์€ ๊ธฐ๋Šฅ๋“ค์„ ์œ„ํ•ด ์–ด๋Š์ •๋„ ๋ผˆ๋Œ€(๊ตฌ์กฐ)๋ฅผ ์ œ๊ณตํ•ด์ฃผ๋Š” ๊ฒƒ. ๊ทธ๋Ÿฌ๋ฏ€๋กœ ๊ทธ๋Ÿฌํ•œ ๋ผˆ๋Œ€ ์œ„์— ํ”„๋กœ๊ทธ๋ž˜๋จธ๊ฐ€ ์ฝ”๋“œ๋ฅผ ์ž‘์„ฑํ•˜์—ฌ Application์„ ์™„์„ฑ์‹œ์ผœ์•ผ ํ•œ๋‹ค. ์–ด๋Š์ •๋„ ๋ผˆ๋Œ€๋ฅผ ์ œ๊ณตํ•ด ์ฃผ๊ธฐ ๋•Œ๋ฌธ์—, ๊ฐ์ฒด ์ง€ํ–ฅ ๊ฐœ๋ฐœ์„ ํ•˜๋ฉด์„œ ์ผ๊ด€์„ฑ ๋ถ€์กฑ ๋“ฑ์˜ ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•ด ์ค€๋‹ค. ๊ทธ๋ž˜์„œ ์†Œํ”„ํŠธ์›จ์–ด์—์„œ๋Š” ํ”„๋ ˆ์ž„์›Œํฌ๋ฅผ ์•„๋ž˜์™€ ๊ฐ™์ด ์ •์˜ํ•˜๊ณค ํ•œ๋‹ค.
์†Œํ”„๋ฅด์›จ์–ด์˜ ํŠน์ • ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•˜๊ธฐ ์œ„ํ•ด์„œ ์ƒํ˜ธ ํ˜‘๋ ฅํ•˜๋Š” ํด๋ž˜์Šค์™€ ์ธํ„ฐํŽ˜์ด์Šค์˜ ์ง‘ํ•ฉ

# Libreay(๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ)

Library๋Š” ํŠน์ • ๊ธฐ๋Šฅ์— ๋Œ€ํ•œ ๋„๊ตฌ or ํ•จ์ˆ˜๋“ค์„ ๋ชจ์€ ์ง‘ํ•ฉ์ด๋‹ค. ์ฆ‰, ํ”„๋กœ๊ทธ๋ž˜๋จธ๊ฐ€ ๊ฐœ๋ฐœํ•˜๋Š”๋ฐ ํ•„์š”ํ•œ ๊ฒƒ๋“ค์„ ๋ชจ์•„๋‘” ๊ฒƒ. Library๋Š” ํ”„๋กœ๊ทธ๋ž˜๋จธ๋ผ๋ฉด ๋ˆ„๊ตฌ๋‚˜ ํ•œ๋ฒˆ์ฏค์€ ์จ๋ดค์„ ๊ฒƒ์ด๋ฉฐ, ์Šค์Šค๋กœ ์จ๋ณด์ง€ ์•Š์•˜๋‹ค๋ผ๊ณ  ์ƒ๊ฐํ•˜๋Š” ์‚ฌ๋žŒ๋„ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๊ฐ€ ๋ฌด์—‡์ธ์ง€ ๋ชฐ๋ผ์„œ ๊ทธ๋ ‡๊ฒŒ ์–˜๊ธฐํ•˜๋Š” ๊ฒƒ์ผ ๋ฟ, ์ž๊ธฐ๋„ ๋ชจ๋ฅด๊ฒŒ ์จ๋ณด์•˜์„ ๊ฒƒ์ด๋‹ค. Library ์—ญ์‹œ๋„ ์•„๋ž˜์™€ ๊ฐ™์ด ๊ฐ„๋‹จํ•˜๊ฒŒ ์ •์˜ํ•  ์ˆ˜ ์žˆ๋‹ค.
๋‹จ์ˆœ ํ™œ์šฉ์ด ๊ฐ€๋Šฅํ•œ ๋„๊ตฌ๋“ค์˜ ์ง‘ํ•ฉ

# ์ฐจ์ด

Framework์™€ Library์˜ ์ฐจ์ด๋Š” Flow(ํ๋ฆ„)์— ๋Œ€ํ•œ ์ œ์–ด ๊ถŒํ•œ์ด ์–ด๋””์— ์žˆ๋Š๋ƒ์˜ ์ฐจ์ด์ด๋‹ค. ํ”„๋ ˆ์ž„์›Œํฌ๋Š” ์ „์ฒด์ ์ธ ํ๋ฆ„์„ ์ž์ฒด์ ์œผ๋กœ ๊ฐ€์ง€๊ณ  ์žˆ์œผ๋ฉฐ, ํ”„๋กœ๊ทธ๋ž˜๋จธ๊ฐ€ ๊ทธ ์•ˆ์— ํ•„์š”ํ•œ ์ฝ”๋“œ๋ฅผ ์ž‘์„ฑํ•˜๋Š” ๋ฐ˜๋ฉด์— ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋Š” ์‚ฌ์šฉ์ž๊ฐ€ ํ๋ฆ„์— ๋Œ€ํ•ด ์ œ์–ด๋ฅผ ํ•˜๋ฉฐ ํ•„์š”ํ•œ ์ƒํ™ฉ์— ๊ฐ€์ ธ๋‹ค ์“ฐ๋Š”๊ฒƒ.

  • ํ”„๋ ˆ์ž„์›Œํฌ์—๋Š” ๋ถ„๋ช…ํ•œ ์ œ์–ด์˜ ์—ญ์ „ ๊ฐœ๋…์ด ์ ์šฉ๋˜์–ด ์žˆ์–ด์•ผ ํ•œ๋‹ค.
  • ์ œ์–ด์˜ ์—ญ์ „์ด๋ž€ ์–ด๋– ํ•œ ์ผ์„ ํ•˜๋„๋ก ๋งŒ๋“ค์–ด์ง„ ํ”„๋ ˆ์ž„์›Œํฌ์— ์ œ์–ด์˜ ๊ถŒํ•œ์„ ๋„˜๊น€์œผ๋กœ์จ ํด๋ผ์ด์–ธํŠธ ์ฝ”๋“œ๊ฐ€ ์‹ ๊ฒฝ ์จ์•ผ ํ•  ๊ฒƒ์„ ์ค„์ด๋Š” ์ „๋žต
Last update: September 13, 2022 21:44
Contributors: ahnjs