Skip to content

Commit

Permalink
TS-38628 Broken mockito
Browse files Browse the repository at this point in the history
  • Loading branch information
Avanatiker committed Dec 4, 2024
1 parent 5579895 commit 1f80e95
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 69 deletions.
1 change: 1 addition & 0 deletions impacted-test-engine/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@ dependencies {
compileOnly(libs.junit.platform.commons)
testImplementation(libs.junit.platform.engine)
testImplementation(libs.junit.jupiter.params)
testImplementation("org.mockito.kotlin:mockito-kotlin:5.4.0")
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package com.teamscale.test_impacted.engine.executor

import com.teamscale.report.testwise.model.TestExecution
import com.teamscale.test_impacted.commons.LoggerUtils.createLogger
import com.teamscale.tia.client.ITestwiseCoverageAgentApi
import com.teamscale.tia.client.UrlUtils.encodeUrl
import java.io.IOException
import java.util.logging.Level

/** Communicates test start and end to the agent and the end of the overall test execution. */
open class TeamscaleAgentNotifier(
/** A list of API services to signal test start and end to the agent. */
private val testwiseCoverageAgentApis: List<ITestwiseCoverageAgentApi>,
/**
* Whether only a part of the tests is being executed (`true`) or whether all tests are executed
* (`false`).
*/
private val partial: Boolean
) {
private val logger = createLogger()

/** Reports the start of a test to the Teamscale JaCoCo agent. */
open fun startTest(testUniformPath: String) {
try {
testwiseCoverageAgentApis.forEach { apiService ->
apiService.testStarted(testUniformPath.encodeUrl()).execute()
}
} catch (e: IOException) {
logger.log(
Level.SEVERE, e
) { "Error while calling service api." }
}
}

/** Reports the end of a test to the Teamscale JaCoCo agent. */
open fun endTest(testUniformPath: String, testExecution: TestExecution?) {
try {
testwiseCoverageAgentApis.forEach { apiService ->
val url = testUniformPath.encodeUrl()
if (testExecution == null) {
apiService.testFinished(url).execute()
} else {
apiService.testFinished(url, testExecution).execute()
}
}
} catch (e: IOException) {
logger.log(
Level.SEVERE, e
) { "Error contacting test wise coverage agent." }
}
}

/** Reports the end of the test run to the Teamscale JaCoCo agent. */
open fun testRunEnded() {
try {
testwiseCoverageAgentApis.forEach { apiService ->
apiService.testRunFinished(partial).execute()
}
} catch (e: IOException) {
logger.log(
Level.SEVERE, e
) { "Error contacting test wise coverage agent." }
}
}
}
2 changes: 1 addition & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ include(":sample-debugging-app")
include(":teamscale-maven-plugin")
include(":installer")

file("system-tests").listFiles { file: File -> !file.isHidden && file.isDirectory }?.forEach { folder ->
file("system-tests").listFiles { file -> !file.isHidden && file.isDirectory }?.forEach { folder ->
include(":system-tests:${folder.name}")
}

0 comments on commit 1f80e95

Please sign in to comment.