Skip to content
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ We use [semantic versioning](http://semver.org/):

# Next version
- [feature] _agent_: Renamed the docker image to `cqse/teamscale-java-profiler` and added support for the `linux/arm64` platform
- [fix] _teamscale-gradle-plugin_: Coverage aggregation report and upload were skipped when tests failed with `--continue`

# 36.4.1
- [fix] _agent_: Fixed `IllegalStateException: Can't add different class with same name` when application servers like JBoss perform a reload without full restart or when duplicate class files exist across multiple archives
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,7 @@ abstract class CompactCoverageAggregationPlugin : Plugin<Project> {
attributes.artifactType(ArtifactTypeDefinition.BINARY_DATA_TYPE)
}.files
this.executionData.from(executionData)
dependsOn(executionData.buildDependencies)
this.classDirectories.from(classDirectories)
dependsOn(classDirectories.buildDependencies)
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
package com.teamscale

import org.assertj.core.api.Assertions.assertThat
import org.gradle.testkit.runner.TaskOutcome
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test

/**
* Tests the compact coverage aggregation plugin across multiple subprojects,
* specifically that the aggregation report is still generated when tests fail with --continue.
*/
class CompactCoverageAggregationTest : TeamscalePluginTestBase() {

@BeforeEach
fun init() {
setupSettings()
setupRootBuildFile()
setupSubprojectMod1()
}

private fun setupSettings() {
rootProject.settingsFile.writeText(
"""
dependencyResolutionManagement {
repositories {
mavenLocal()
mavenCentral()
}
}

include 'mod1'
""".trimIndent()
)
}

private fun setupRootBuildFile() {
rootProject.buildFile.writeText(
"""
import com.teamscale.aggregation.TestSuiteCompatibilityUtil
import com.teamscale.aggregation.compact.AggregateCompactCoverageReport

plugins {
id 'java'
id 'com.teamscale'
id 'com.teamscale.aggregation'
}

teamscale {
commit {
revision = "abcd1337"
}
repository = "myRepoId"
}

dependencies {
reportAggregation(subprojects)
}

reporting {
reports {
unitTestAggregateCompactCoverageReport(AggregateCompactCoverageReport) { testSuiteName = 'unitTest' }
}
}

subprojects {
apply plugin: 'com.teamscale'

tasks.register('runUnitTests', Test) {
useJUnitPlatform()
testClassesDirs = sourceSets.test.output.classesDirs
classpath = sourceSets.test.runtimeClasspath
}
TestSuiteCompatibilityUtil.exposeTestForAggregation(tasks.named('runUnitTests'), 'unitTest')
}
""".trimIndent()
)

Check warning on line 76 in teamscale-gradle-plugin/src/test/kotlin/com/teamscale/CompactCoverageAggregationTest.kt

View check run for this annotation

cqse.teamscale.io / Teamscale | Findings

teamscale-gradle-plugin/src/test/kotlin/com/teamscale/CompactCoverageAggregationTest.kt#L37-L76

[New] Violation of method length threshold (source lines of code) of 30: 34 https://cqse.teamscale.io/findings/details/teamscale-java-profiler?t=ts%2F46135_coverage_aggregation_test_fail%3AHEAD&id=7CDF5A0800B2310CF6E8A259E6126A34
}

private fun setupSubprojectMod1() {
java.io.File(rootProject.dir("mod1"), "build.gradle").writeText(
"""
plugins {
id 'java'
}

dependencies {
testImplementation(platform("org.junit:junit-bom:5.12.0"))
testImplementation("org.junit.jupiter:junit-jupiter")
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
}
""".trimIndent()
)

rootProject.file("mod1/src/main/java/com/example/Lib.java").writeText(
"""
package com.example;

public class Lib {
public static int add(int a, int b) {
return a + b;
}
}
""".trimIndent()
)

rootProject.file("mod1/src/test/java/com/example/LibTest.java").writeText(
"""
package com.example;

import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;

class LibTest {
@Test
void failingTest() {
assertEquals(3, Lib.add(1, 2));
throw new RuntimeException("intentional failure");
}
}
""".trimIndent()
)

Check warning on line 121 in teamscale-gradle-plugin/src/test/kotlin/com/teamscale/CompactCoverageAggregationTest.kt

View check run for this annotation

cqse.teamscale.io / Teamscale | Findings

teamscale-gradle-plugin/src/test/kotlin/com/teamscale/CompactCoverageAggregationTest.kt#L80-L121

[New] Violation of method length threshold (source lines of code) of 30: 36 https://cqse.teamscale.io/findings/details/teamscale-java-profiler?t=ts%2F46135_coverage_aggregation_test_fail%3AHEAD&id=D21CBE12B62F7E30AACF2DAC11D308D4
}

@Test
fun `compact coverage aggregation runs despite test failure with --continue`() {
val build = runExpectingError("--continue", "clean", "unitTestAggregateCompactCoverageReport")

assertThat(build.task(":mod1:runUnitTests")?.outcome)
.isEqualTo(TaskOutcome.FAILED)
assertThat(build.task(":unitTestAggregateCompactCoverageReport")?.outcome)
.isEqualTo(TaskOutcome.SUCCESS)
}
}
Loading