Skip to content

Commit

Permalink
TS-38628 Update some docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Avanatiker committed Jan 6, 2025
1 parent 3b37ede commit 4be0d76
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package com.teamscale.test_impacted.commons
/** Utility class for writing lines with tab indentation. */
class IndentingWriter {
private val builder = StringBuilder()

private var indent = 0

/** Indents all [writeLine] calls in the indented writes by one more tab. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,19 @@ package com.teamscale.test_impacted.engine
import com.teamscale.test_impacted.engine.executor.ITestSorter
import com.teamscale.test_impacted.engine.executor.TeamscaleAgentNotifier

/** Container for a configuration used by the [ImpactedTestEngine] */
/**
* Configuration class for the Impacted Test Engine, responsible for managing dependencies and behavior
* required for executing impacted tests. It provides access to utilities for test data management,
* test engine discovery, test sorting, and interaction with external agents.
*
* @property testDataWriter Used to handle the writing of test execution data and test details to files.
* @property testEngineRegistry Manages and provides access to available test engines, filtering and iterating over them.
* @property testSorter Defines the logic for selecting and sorting tests for execution.
* @property teamscaleAgentNotifier Facilitates communication with the Teamscale test-wise coverage agent by signaling test lifecycle events.
*/
class ImpactedTestEngineConfiguration(
/** The directory to write testwise coverage and available tests to. */
val testDataWriter: TestDataWriter,
/** The test engine registry used to determine the [TestEngine]s to use. */
val testEngineRegistry: TestEngineRegistry,
/** The [ITestSorter] to use for execution of tests. */
val testSorter: ITestSorter,
/** An API to signal test start and end to the agent. */
val teamscaleAgentNotifier: TeamscaleAgentNotifier
)
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@ 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. */
/**
* A notifier class responsible for communicating with the Teamscale JaCoCo agent in test-wise coverage mode.
* It sends signals for test start, test end, and test run completion events to the specified APIs.
*
* @param testwiseCoverageAgentApis A list of API services used to signal test actions to the Teamscale agent.
* @param partial Indicates whether only a subset of tests is executed (`true`) or all tests are executed (`false`).
*/
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
) {
companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,18 @@ import java.io.StringWriter
import java.util.*

/**
* An execution listener which delegates events to another [EngineExecutionListener] and notifies Teamscale agents
* collecting test wise coverage.
* An implementation of [EngineExecutionListener] that collects test-wise coverage information during
* test execution and notifies the corresponding Teamscale agent.
*
* This class acts as a bridge between the JUnit Platform test execution lifecycle and the
* Teamscale JaCoCo agent to record test-wise coverage results. It tracks test execution status
* (e.g. started, skipped, finished) and aggregates results for individual tests or groups of tests.
*
* @param teamscaleAgentNotifier The notifier responsible for signaling test events to the Teamscale JaCoCo agent.
* @param testDescriptorResolver A resolver interface used to map [TestDescriptor] objects to uniform paths.
* @param delegateEngineExecutionListener The underlying [EngineExecutionListener] to which events are delegated.
*/
class TestwiseCoverageCollectingExecutionListener(
/** An API to signal test start and end to the agent. */
private val teamscaleAgentNotifier: TeamscaleAgentNotifier,
private val testDescriptorResolver: ITestDescriptorResolver,
private val delegateEngineExecutionListener: EngineExecutionListener
Expand Down Expand Up @@ -143,15 +150,12 @@ class TestwiseCoverageCollectingExecutionListener(
TestExecutionResult.Status.SUCCESSFUL -> return TestExecution(
testUniformPath, duration, ETestExecutionResult.PASSED
)

TestExecutionResult.Status.ABORTED -> return TestExecution(
testUniformPath, duration, ETestExecutionResult.ERROR, message
)

TestExecutionResult.Status.FAILED -> return TestExecution(
testUniformPath, duration, ETestExecutionResult.FAILURE, message
)

else -> {
LOG.severe { "Got unexpected test execution result status: $status" }
return null
Expand All @@ -161,9 +165,7 @@ class TestwiseCoverageCollectingExecutionListener(

/** Extracts the stacktrace from the given [Throwable] into a string or returns null if no throwable is given. */
private fun Optional<Throwable>.buildStacktrace(): String? {
if (!isPresent) {
return null
}
if (!isPresent) return null

val sw = StringWriter()
val pw = PrintWriter(sw)
Expand Down

0 comments on commit 4be0d76

Please sign in to comment.