Skip to content

Nested Class Exclusions #394

@ciaranduncan14596

Description

@ciaranduncan14596

Hi team,

We have a scala project like the the following- lets say TestController.scala

import scala.concurrent.ExecutionContext

class TestController @Inject() (
  testProvider: TestProvider
)(implicit executionContext: ExecutionContext, metrics: Metrics)
  extends Framework.RestApi {

  private val Tag = "test"

  prefix("/api/v1") {
    getWithDoc("/test") {
      _.summary("test")
        .tag(Tag)
        .request[TestRequest]
        .responseWith[GenericResponse[TestResponse]](status = 200)
    } { req: TestReq =>
      {
        for {
          res <- testProvider.getStuff(req.id)
        } yield GenericResponse[TestResponse](res)
      }
    }
  }
}

case class TestRequest(
  @Inject request: Request
) extends HasAuthentication

case class TestResponse(
  results: Seq[String] = Seq.empty[String]
)

Our issue is that the TestRequest and TestResponse here appear as uncovered classes in our Report. Is there a way we can get around this? e.g a custom decorator for example. I've also included our JacocoSettings

lazy val jacocoSettings = Seq(
  jacocoReportSettings := JacocoReportSettings(
    "Jacoco Coverage Report",
    None,
    JacocoThresholds(instruction=80, method=80, branch=80, complexity=0, line=80, clazz=0),
    Seq(JacocoReportFormats.ScalaHTML, JacocoReportFormats.XML, JacocoReportFormats.CSV), // HTML + XML + CSV for Jenkins/Sonar integration
    "utf-8"
  ),
  jacocoExcludes := Seq(
    "*.thrift.*", 
    "*Routes*",
    "*Routes$*",
    "*Config*",
    "*lifecycle*",
    "*modules*",
    "*model*",
    "*Module*",
    "*App*",
    "*Server*", 
    "*Exception*", 
    "*.g8.*",
    "*repl*"
  ),
  // Ensure Jacoco works with forked tests
  Test / fork := false, // Disable forking for tests to avoid Jacoco agent issues
  // If forking is absolutely necessary, uncomment the lines below:
  // Test / javaOptions ++= (Test / jacocoAgentOptions).value
)

Any advice would be great!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions