Skip to content

Commit

Permalink
Fix: test method coverage 조건 삭제
Browse files Browse the repository at this point in the history
  • Loading branch information
adorableco committed Oct 5, 2024
1 parent 16bf3a4 commit 088d405
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 45 deletions.
8 changes: 1 addition & 7 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
51 changes: 51 additions & 0 deletions src/test/kotlin/com/swm_standard/phote/entity/ExamResultTest.kt
Original file line number Diff line number Diff line change
@@ -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)
}
}
38 changes: 1 addition & 37 deletions src/test/kotlin/com/swm_standard/phote/entity/ExamTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -19,48 +15,16 @@ 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)

assertThat(exam.workbook).isEqualTo(workbook)
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)
}
}
13 changes: 13 additions & 0 deletions src/test/kotlin/com/swm_standard/phote/entity/WorkbookTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 088d405

Please sign in to comment.