Skip to content

Commit 07e4ffb

Browse files
BAEL:7966 sgrverma23 - changes for Gradle JUnit Generate HTML Report (#18801)
* BAEL:7966 by sgrverma23 - changes for Gradle JUnit Generate HTML Report * removing auto-generated dependencies * renaming test file * refactoring --------- Co-authored-by: sverma1-godaddy <[email protected]>
1 parent 68771f4 commit 07e4ffb

File tree

14 files changed

+195
-0
lines changed

14 files changed

+195
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
plugins {
2+
id("java")
3+
id("jvm-test-suite")
4+
id("test-report-aggregation")
5+
}
6+
7+
group = "com.baeldung.gradle"
8+
version = "1.0-SNAPSHOT"
9+
10+
repositories {
11+
mavenCentral()
12+
}
13+
14+
dependencies {
15+
testImplementation("org.junit.jupiter:junit-jupiter:5.10.0")
16+
}
17+
18+
testing {
19+
suites {
20+
val test by getting(JvmTestSuite::class) {
21+
useJUnitJupiter()
22+
}
23+
}
24+
}
25+
26+
reporting {
27+
reports {
28+
val testAggregateTestReport by existing(AggregateTestReport::class)
29+
}
30+
}
31+
32+
dependencies {
33+
subprojects.forEach { sub ->
34+
testReportAggregation(project(sub.path))
35+
}
36+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
plugins {
2+
id("java-library")
3+
id("jvm-test-suite")
4+
}
5+
6+
repositories {
7+
mavenCentral()
8+
}
9+
10+
testing {
11+
suites {
12+
val test by getting(JvmTestSuite::class) {
13+
useJUnitJupiter()
14+
}
15+
}
16+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.baeldung.gradle.firstmodule;
2+
3+
import org.junit.jupiter.api.BeforeEach;
4+
import org.junit.jupiter.api.Test;
5+
6+
import static org.junit.jupiter.api.Assertions.assertEquals;
7+
import static org.junit.jupiter.api.Assertions.assertThrows;
8+
9+
public class ModuleATest {
10+
11+
@Test
12+
void givenNumbers_whenAdd_thenCorrect() {
13+
int sum = 2 + 3;
14+
assertEquals(5, sum);
15+
}
16+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
plugins {
2+
id("java-library")
3+
id("jvm-test-suite")
4+
}
5+
6+
repositories {
7+
mavenCentral()
8+
}
9+
10+
testing {
11+
suites {
12+
val test by getting(JvmTestSuite::class) {
13+
useJUnitJupiter()
14+
}
15+
}
16+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.baeldung.gradle.secondmodule;
2+
3+
import org.junit.jupiter.api.Test;
4+
import static org.junit.jupiter.api.Assertions.assertTrue;
5+
6+
public class ModuleBTest {
7+
8+
@Test
9+
void givenString_whenCheckLength_thenCorrect() {
10+
String word = "Hello World";
11+
assertTrue(word.length() > 3);
12+
}
13+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
rootProject.name = "junit-report-multi-module"
2+
include("modulea", "moduleb")
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
plugins {
2+
id("java")
3+
id("jacoco")
4+
}
5+
6+
group = "com.baeldung.gradle"
7+
version = "1.0-SNAPSHOT"
8+
9+
repositories {
10+
mavenCentral()
11+
}
12+
13+
dependencies {
14+
testImplementation(platform("org.junit:junit-bom:5.10.0"))
15+
testImplementation("org.junit.jupiter:junit-jupiter")
16+
}
17+
18+
tasks.test {
19+
useJUnitPlatform()
20+
21+
reports {
22+
html.required = true
23+
junitXml.required = true
24+
}
25+
26+
finalizedBy(tasks.jacocoTestReport)
27+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
rootProject.name = "junit-report-single-module"

0 commit comments

Comments
 (0)