From 088d40579f61a1892358db655e1c4208d552e890 Mon Sep 17 00:00:00 2001
From: adorableco <tpdusdl1001@knu.ac.kr>
Date: Sat, 5 Oct 2024 19:02:16 +0900
Subject: [PATCH] =?UTF-8?q?Fix:=20test=20method=20coverage=20=EC=A1=B0?=
 =?UTF-8?q?=EA=B1=B4=20=EC=82=AD=EC=A0=9C?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 build.gradle.kts                              |  8 +--
 .../swm_standard/phote/entity/AnswerTest.kt   |  1 -
 .../phote/entity/ExamResultTest.kt            | 51 +++++++++++++++++++
 .../com/swm_standard/phote/entity/ExamTest.kt | 38 +-------------
 .../swm_standard/phote/entity/WorkbookTest.kt | 13 +++++
 5 files changed, 66 insertions(+), 45 deletions(-)
 create mode 100644 src/test/kotlin/com/swm_standard/phote/entity/ExamResultTest.kt

diff --git a/build.gradle.kts b/build.gradle.kts
index b6a2fc2..950dc31 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -181,13 +181,7 @@ tasks.jacocoTestCoverageVerification {
             limit {
                 counter = "BRANCH"
                 value = "COVEREDRATIO"
-                minimum = 0.50.toBigDecimal()
-            }
-
-            limit {
-                counter = "METHOD"
-                value = "COVEREDRATIO"
-                minimum = 0.30.toBigDecimal()
+                minimum = 0.60.toBigDecimal()
             }
 
             val qDomains = emptyList<String>().toMutableList()
diff --git a/src/test/kotlin/com/swm_standard/phote/entity/AnswerTest.kt b/src/test/kotlin/com/swm_standard/phote/entity/AnswerTest.kt
index a6571c6..c14d228 100644
--- a/src/test/kotlin/com/swm_standard/phote/entity/AnswerTest.kt
+++ b/src/test/kotlin/com/swm_standard/phote/entity/AnswerTest.kt
@@ -21,7 +21,6 @@ class AnswerTest {
     @Test
     fun `문제가 객관식이면 정오답 체크한다`() {
         val submittedAnswer = Arbitraries.strings().numeric().sample()
-        val category = Category.MULTIPLE
         val correctAnswer = Arbitraries.strings().numeric().sample()
         val answer =
             fixtureMonkey
diff --git a/src/test/kotlin/com/swm_standard/phote/entity/ExamResultTest.kt b/src/test/kotlin/com/swm_standard/phote/entity/ExamResultTest.kt
new file mode 100644
index 0000000..573c97f
--- /dev/null
+++ b/src/test/kotlin/com/swm_standard/phote/entity/ExamResultTest.kt
@@ -0,0 +1,51 @@
+package com.swm_standard.phote.entity
+
+import com.navercorp.fixturemonkey.FixtureMonkey
+import com.navercorp.fixturemonkey.api.introspector.FieldReflectionArbitraryIntrospector
+import com.navercorp.fixturemonkey.kotlin.KotlinPlugin
+import com.navercorp.fixturemonkey.kotlin.giveMeBuilder
+import com.navercorp.fixturemonkey.kotlin.setExp
+import com.navercorp.fixturemonkey.kotlin.sizeExp
+import org.assertj.core.api.Assertions.assertThat
+import org.junit.jupiter.api.Assertions.assertEquals
+import org.junit.jupiter.api.Test
+
+class ExamResultTest {
+    private val fixtureMonkey =
+        FixtureMonkey
+            .builder()
+            .plugin(KotlinPlugin())
+            .objectIntrospector(FieldReflectionArbitraryIntrospector.INSTANCE)
+            .build()
+
+    @Test
+    fun `문제 풀이한 총 문제수를 구한다`() {
+        // given
+        val exam: ExamResult =
+            fixtureMonkey
+                .giveMeBuilder<ExamResult>()
+                .sizeExp(ExamResult::answers, 2)
+                .sample()
+
+        // when
+        val totalQuantity = exam.calculateTotalQuantity()
+
+        // then
+        assertEquals(totalQuantity, 2)
+    }
+
+    @Test
+    fun `totalCorrect가 증가한다`() {
+        val count = 3
+        val totalCorrect = 2
+        val exam =
+            fixtureMonkey
+                .giveMeBuilder<ExamResult>()
+                .setExp(ExamResult::totalCorrect, totalCorrect)
+                .sample()
+
+        exam.increaseTotalCorrect(count)
+
+        assertThat(exam.totalCorrect).isEqualTo(totalCorrect + count)
+    }
+}
diff --git a/src/test/kotlin/com/swm_standard/phote/entity/ExamTest.kt b/src/test/kotlin/com/swm_standard/phote/entity/ExamTest.kt
index db6a6cf..2228a7c 100644
--- a/src/test/kotlin/com/swm_standard/phote/entity/ExamTest.kt
+++ b/src/test/kotlin/com/swm_standard/phote/entity/ExamTest.kt
@@ -3,12 +3,8 @@ package com.swm_standard.phote.entity
 import com.navercorp.fixturemonkey.FixtureMonkey
 import com.navercorp.fixturemonkey.api.introspector.FieldReflectionArbitraryIntrospector
 import com.navercorp.fixturemonkey.kotlin.KotlinPlugin
-import com.navercorp.fixturemonkey.kotlin.giveMeBuilder
 import com.navercorp.fixturemonkey.kotlin.giveMeOne
-import com.navercorp.fixturemonkey.kotlin.setExp
-import com.navercorp.fixturemonkey.kotlin.sizeExp
 import org.assertj.core.api.Assertions.assertThat
-import org.junit.jupiter.api.Assertions.assertEquals
 import org.junit.jupiter.api.Test
 
 class ExamTest {
@@ -19,28 +15,11 @@ class ExamTest {
             .objectIntrospector(FieldReflectionArbitraryIntrospector.INSTANCE)
             .build()
 
-    @Test
-    fun `문제 풀이한 총 문제수를 구한다`() {
-        // given
-        val exam: ExamResult =
-            fixtureMonkey
-                .giveMeBuilder<ExamResult>()
-                .sizeExp(ExamResult::answers, 2)
-                .sample()
-
-        // when
-        val totalQuantity = exam.calculateTotalQuantity()
-
-        // then
-        assertEquals(totalQuantity, 2)
-    }
-
     @Test
     fun `시험 생성에 성공한다`() {
         val workbook: Workbook = fixtureMonkey.giveMeOne()
         val member: Member = fixtureMonkey.giveMeOne()
-        val sequence: Int = 2
-        val time = 20
+        val sequence = 2
 
         val exam = Exam.createExam(member, workbook, sequence)
 
@@ -48,19 +27,4 @@ class ExamTest {
         assertThat(exam.member.name).isEqualTo(member.name)
         assertThat(exam.sequence).isEqualTo(sequence)
     }
-
-    @Test
-    fun `totalCorrect가 증가한다`() {
-        val count = 3
-        val totalCorrect = 2
-        val exam =
-            fixtureMonkey
-                .giveMeBuilder<ExamResult>()
-                .setExp(ExamResult::totalCorrect, totalCorrect)
-                .sample()
-
-        exam.increaseTotalCorrect(count)
-
-        assertThat(exam.totalCorrect).isEqualTo(totalCorrect + count)
-    }
 }
diff --git a/src/test/kotlin/com/swm_standard/phote/entity/WorkbookTest.kt b/src/test/kotlin/com/swm_standard/phote/entity/WorkbookTest.kt
index 5bde53a..d27baeb 100644
--- a/src/test/kotlin/com/swm_standard/phote/entity/WorkbookTest.kt
+++ b/src/test/kotlin/com/swm_standard/phote/entity/WorkbookTest.kt
@@ -47,6 +47,19 @@ class WorkbookTest {
         assertThat(workbook.emoji).isEqualTo("💬")
     }
 
+    @Test
+    fun `문제집 내용에 해당하는 키워드가 없으면 📚이모지로 세팅한다`() {
+        val workbook: Workbook = fixtureMonkey.giveMeOne()
+        val modifiedTitle = "asdsaddsdf 축구 야구"
+        val modifiedDescription: String? = Arbitraries.strings().injectNull(0.3).sample()
+
+        workbook.updateWorkbook(modifiedTitle, modifiedDescription)
+
+        assertThat(workbook.title).isEqualTo(modifiedTitle)
+        assertThat(workbook.description).isEqualTo(modifiedDescription)
+        assertThat(workbook.emoji).isEqualTo("📚")
+    }
+
     @Test
     fun `문제 1개 삭제 시에 quantity가 1만큼 줄어든다`() {
         val testNum: Int = Arbitraries.integers().greaterOrEqual(1).sample()