Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kotlin: adds approval test setup #8

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions expensereport-kotlin/Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
.PHONY: all
all: build

.PHONY: build clean pitest
build clean pitest:
.PHONY: build clean test pitest
build clean test pitest:
./gradlew $@

-include .User.mk
Expand Down
2 changes: 2 additions & 0 deletions expensereport-kotlin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ dependencyManagement {
}
dependency("org.pitest:pitest-junit5-plugin:0.15")
dependency("org.pitest:pitest-command-line:1.8.0")
dependency("com.approvaltests:approvaltests:15.6.0")
}
}

Expand All @@ -63,6 +64,7 @@ dependencies {
testImplementation("org.junit.platform:junit-platform-suite-api")
testImplementation("org.junit.platform:junit-platform-suite-commons")
testImplementation("org.junit.platform:junit-platform-suite-engine")
testImplementation("com.approvaltests:approvaltests")
}

tasks.withType<KotlinCompile> {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.nelkinda.training

import org.approvaltests.ApprovalUtilities
import org.approvaltests.Approvals
import org.junit.jupiter.api.Test

class ExpenseReportApprovalTest {

@Test
fun test() {
val output = ApprovalUtilities().writeSystemOutToStringBuffer()

val expense = Expense()
expense.type = ExpenseType.BREAKFAST
expense.amount = 500

ExpenseReport().printReport(listOf(expense))

// will fail, because of timestamp in expense report
Approvals.verify(output)
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Expenses Fri Jun 03 12:02:48 CEST 2022
Breakfast 500
Meal expenses: 500
Total expenses: 500