Skip to content

Commit a820c28

Browse files
committed
fixed problem in Calc game, added tests coverage
1 parent 2fe9496 commit a820c28

File tree

4 files changed

+24
-113
lines changed

4 files changed

+24
-113
lines changed

app/build.gradle.kts

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
plugins {
2-
id("java")
3-
id("application")
4-
id("checkstyle")
2+
application
3+
java
4+
checkstyle
5+
id("org.jetbrains.kotlin.jvm") version "1.8.10"
6+
id("jacoco")
57
}
68

79
group = "hexlet.code"
@@ -12,7 +14,7 @@ repositories {
1214
}
1315

1416
application {
15-
mainClass = "hexlet.code.App"
17+
mainClass.set("hexlet.code.App")
1618
}
1719

1820
dependencies {
@@ -22,15 +24,27 @@ dependencies {
2224

2325
tasks.test {
2426
useJUnitPlatform()
27+
finalizedBy("jacocoTestReport") // Ссылаемся на задачу по имени, чтобы она выполнялась после тестов
2528
}
2629

27-
tasks.getByName("run", JavaExec::class) {
28-
standardInput = System.`in`
30+
tasks.named<JacocoReport>("jacocoTestReport") {
31+
dependsOn(tasks.test) // Задаем зависимость от задачи тестирования
32+
reports {
33+
xml.required.set(true) // Генерация XML отчета
34+
html.required.set(true) // Генерация HTML отчета
35+
}
36+
}
2937

38+
jacoco {
39+
toolVersion = "0.8.7"
40+
}
41+
42+
tasks.getByName<JavaExec>("run") {
43+
standardInput = System.`in`
3044
}
3145

3246
checkstyle {
33-
toolVersion = "10.12.4" // Устанавливаем версию Checkstyle
47+
toolVersion = "10.12.4"
3448
}
3549

3650
tasks.withType<Checkstyle>().configureEach {

app/game2Even.cast

Lines changed: 0 additions & 58 deletions
This file was deleted.

app/gameEven.cast

Lines changed: 0 additions & 45 deletions
This file was deleted.

app/src/main/java/hexlet/code/games/Calc.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ public static int calc() {
2020
int randomNumber1 = random.nextInt(19) + 1;
2121
int randomNumber2 = random.nextInt(9) + 1;
2222

23-
String plus = randomNumber1 + "+" + randomNumber2;
24-
String minus = randomNumber1 + "-" + randomNumber2;
25-
String mult = randomNumber1 + "*" + randomNumber2;
23+
String plus = randomNumber1 + " + " + randomNumber2;
24+
String minus = randomNumber1 + " - " + randomNumber2;
25+
String mult = randomNumber1 + " * " + randomNumber2;
2626

2727
List<String> randomExpression = Arrays.asList(plus, minus, mult);
2828
Random rand = new Random();

0 commit comments

Comments
 (0)