From f51d308b44b58772aabfd0d11686a94cad711879 Mon Sep 17 00:00:00 2001 From: John Green Date: Wed, 6 Mar 2024 10:56:08 +0000 Subject: [PATCH] APIS-6903: Subprojects for integration and component tests (#81) --- .scalafmt.conf | 2 +- build.sbt | 58 ++++++++++--------- .../NotificationCallbackConnectorISpec.scala | 0 .../connectors/OutboundConnectorISpec.scala | 0 .../OutboundMessageRepositoryISpec.scala | 0 .../support/Ccn2Service.scala | 0 .../support/NotificationsService.scala | 0 .../support/WireMockSupport.scala | 0 project/AppDependencies.scala | 16 ++--- project/plugins.sbt | 25 ++++---- 10 files changed, 51 insertions(+), 50 deletions(-) rename it/{ => test}/uk/gov/hmrc/apiplatformoutboundsoap/connectors/NotificationCallbackConnectorISpec.scala (100%) rename it/{ => test}/uk/gov/hmrc/apiplatformoutboundsoap/connectors/OutboundConnectorISpec.scala (100%) rename it/{ => test}/uk/gov/hmrc/apiplatformoutboundsoap/repositories/OutboundMessageRepositoryISpec.scala (100%) rename it/{ => test}/uk/gov/hmrc/apiplatformoutboundsoap/support/Ccn2Service.scala (100%) rename it/{ => test}/uk/gov/hmrc/apiplatformoutboundsoap/support/NotificationsService.scala (100%) rename it/{ => test}/uk/gov/hmrc/apiplatformoutboundsoap/support/WireMockSupport.scala (100%) diff --git a/.scalafmt.conf b/.scalafmt.conf index e70ac47..5ac8eb7 100644 --- a/.scalafmt.conf +++ b/.scalafmt.conf @@ -1,4 +1,4 @@ -version="3.5.3" +version="3.7.17" runner.dialect = "scala213" maxColumn = 180 diff --git a/build.sbt b/build.sbt index 7d13c50..493c26a 100644 --- a/build.sbt +++ b/build.sbt @@ -1,11 +1,13 @@ -import uk.gov.hmrc.DefaultBuildSettings.integrationTestSettings +import uk.gov.hmrc.DefaultBuildSettings +import uk.gov.hmrc.DefaultBuildSettings._ val appName = "api-platform-outbound-soap" -val silencerVersion = "1.7.9" - -scalaVersion := "2.13.12" +Global / bloopAggregateSourceDependencies := true +Global / bloopExportJarClassifiers := Some(Set("sources")) +ThisBuild / scalaVersion := "2.13.12" +ThisBuild / majorVersion := 0 ThisBuild / libraryDependencySchemes += "org.scala-lang.modules" %% "scala-xml" % VersionScheme.Always ThisBuild / semanticdbEnabled := true ThisBuild / semanticdbVersion := scalafixSemanticdb.revision @@ -14,35 +16,37 @@ lazy val microservice = Project(appName, file(".")) .enablePlugins(PlayScala, SbtDistributablesPlugin) .disablePlugins(JUnitXmlReportPlugin) .settings( - majorVersion := 0, - PlayKeys.playDefaultPort := 6703, - libraryDependencies ++= AppDependencies.compile ++ AppDependencies.test, - dependencyOverrides ++= AppDependencies.axiomOverrides, + PlayKeys.playDefaultPort := 6703, + libraryDependencies ++= AppDependencies(), + dependencyOverrides ++= AppDependencies.axiomOverrides, + retrieveManaged := true, + // https://www.scala-lang.org/2021/01/12/configuring-and-suppressing-warnings.html + // suppress warnings in generated routes files + scalacOptions += "-Wconf:src=routes/.*:s" ) .settings(ScoverageSettings()) - .configs(IntegrationTest) - .settings(integrationTestSettings(): _*) - .settings(scalafixConfigSettings(IntegrationTest)) - .settings( - IntegrationTest / unmanagedResourceDirectories += baseDirectory.value / "test" / "resources" - ) .settings( - Compile / unmanagedResourceDirectories += baseDirectory.value / "app" / "resources" + Compile / unmanagedResourceDirectories += baseDirectory.value / "app" / "resources", + Test / unmanagedResourceDirectories += baseDirectory.value / "test" / "resources" ) + +lazy val it = (project in file("it")) + .enablePlugins(PlayScala) + .dependsOn(microservice % "test->test") .settings( - scalacOptions ++= Seq( - "-Wconf:cat=unused&src=views/.*\\.scala:s", - "-Wconf:cat=unused&src=.*RoutesPrefix\\.scala:s", - "-Wconf:cat=unused&src=.*Routes\\.scala:s", - "-Wconf:cat=unused&src=.*ReverseRoutes\\.scala:s" - ) + name := "integration-tests", + Test / testOptions += Tests.Argument(TestFrameworks.ScalaTest, "-eT"), + DefaultBuildSettings.itSettings(), + addTestReportOption(Test, "int-test-reports") ) commands ++= Seq( - Command.command("run-all-tests") { state => "test" :: "it:test" :: state }, - - Command.command("clean-and-test") { state => "clean" :: "compile" :: "run-all-tests" :: state }, - - // Coverage does not need compile ! - Command.command("pre-commit") { state => "clean" :: "scalafmtAll" :: "scalafixAll" :: "coverage" :: "run-all-tests" :: "coverageOff" :: "coverageAggregate" :: state } + Command.command("cleanAll") { state => "clean" :: "it/clean" :: state }, + Command.command("fmtAll") { state => "scalafmtAll" :: "it/scalafmtAll" :: state }, + Command.command("fixAll") { state => "scalafixAll" :: "it/scalafixAll" :: state }, + Command.command("testAll") { state => "test" :: "it/test" :: state }, + + Command.command("run-all-tests") { state => "testAll" :: state }, + Command.command("clean-and-test") { state => "cleanAll" :: "compile" :: "run-all-tests" :: state }, + Command.command("pre-commit") { state => "cleanAll" :: "fmtAll" :: "fixAll" :: "coverage" :: "testAll" :: "coverageOff" :: "coverageAggregate" :: state } ) diff --git a/it/uk/gov/hmrc/apiplatformoutboundsoap/connectors/NotificationCallbackConnectorISpec.scala b/it/test/uk/gov/hmrc/apiplatformoutboundsoap/connectors/NotificationCallbackConnectorISpec.scala similarity index 100% rename from it/uk/gov/hmrc/apiplatformoutboundsoap/connectors/NotificationCallbackConnectorISpec.scala rename to it/test/uk/gov/hmrc/apiplatformoutboundsoap/connectors/NotificationCallbackConnectorISpec.scala diff --git a/it/uk/gov/hmrc/apiplatformoutboundsoap/connectors/OutboundConnectorISpec.scala b/it/test/uk/gov/hmrc/apiplatformoutboundsoap/connectors/OutboundConnectorISpec.scala similarity index 100% rename from it/uk/gov/hmrc/apiplatformoutboundsoap/connectors/OutboundConnectorISpec.scala rename to it/test/uk/gov/hmrc/apiplatformoutboundsoap/connectors/OutboundConnectorISpec.scala diff --git a/it/uk/gov/hmrc/apiplatformoutboundsoap/repositories/OutboundMessageRepositoryISpec.scala b/it/test/uk/gov/hmrc/apiplatformoutboundsoap/repositories/OutboundMessageRepositoryISpec.scala similarity index 100% rename from it/uk/gov/hmrc/apiplatformoutboundsoap/repositories/OutboundMessageRepositoryISpec.scala rename to it/test/uk/gov/hmrc/apiplatformoutboundsoap/repositories/OutboundMessageRepositoryISpec.scala diff --git a/it/uk/gov/hmrc/apiplatformoutboundsoap/support/Ccn2Service.scala b/it/test/uk/gov/hmrc/apiplatformoutboundsoap/support/Ccn2Service.scala similarity index 100% rename from it/uk/gov/hmrc/apiplatformoutboundsoap/support/Ccn2Service.scala rename to it/test/uk/gov/hmrc/apiplatformoutboundsoap/support/Ccn2Service.scala diff --git a/it/uk/gov/hmrc/apiplatformoutboundsoap/support/NotificationsService.scala b/it/test/uk/gov/hmrc/apiplatformoutboundsoap/support/NotificationsService.scala similarity index 100% rename from it/uk/gov/hmrc/apiplatformoutboundsoap/support/NotificationsService.scala rename to it/test/uk/gov/hmrc/apiplatformoutboundsoap/support/NotificationsService.scala diff --git a/it/uk/gov/hmrc/apiplatformoutboundsoap/support/WireMockSupport.scala b/it/test/uk/gov/hmrc/apiplatformoutboundsoap/support/WireMockSupport.scala similarity index 100% rename from it/uk/gov/hmrc/apiplatformoutboundsoap/support/WireMockSupport.scala rename to it/test/uk/gov/hmrc/apiplatformoutboundsoap/support/WireMockSupport.scala diff --git a/project/AppDependencies.scala b/project/AppDependencies.scala index 5eec6fc..0cb1e2a 100644 --- a/project/AppDependencies.scala +++ b/project/AppDependencies.scala @@ -5,21 +5,23 @@ object AppDependencies { val bootstrapPlayVersion = "8.4.0" val mongoVersion = "1.7.0" + def apply(): Seq[ModuleID] = compile ++ test + val compile = Seq( "uk.gov.hmrc" %% "bootstrap-backend-play-30" % bootstrapPlayVersion, "uk.gov.hmrc.mongo" %% "hmrc-mongo-play-30" % mongoVersion, "org.apache.pekko" %% "pekko-connectors-mongodb" % "1.0.2", - "org.apache.axis2" % "axis2-kernel" % "1.8.0", - "org.apache.wss4j" % "wss4j-ws-security-dom" % "2.4.1", + "org.apache.axis2" % "axis2-kernel" % "1.8.2", + "org.apache.wss4j" % "wss4j-ws-security-dom" % "2.4.3", caffeine ) val test = Seq( - "uk.gov.hmrc" %% "bootstrap-test-play-30" % bootstrapPlayVersion % "test, it", - "org.mockito" %% "mockito-scala-scalatest" % "1.17.29" % "test, it", - "org.xmlunit" % "xmlunit-core" % "2.9.0" % "test, it", - "uk.gov.hmrc.mongo" %% "hmrc-mongo-test-play-30" % mongoVersion % "it" - ) + "uk.gov.hmrc" %% "bootstrap-test-play-30" % bootstrapPlayVersion, + "org.mockito" %% "mockito-scala-scalatest" % "1.17.30", + "org.xmlunit" % "xmlunit-core" % "2.9.0", + "uk.gov.hmrc.mongo" %% "hmrc-mongo-test-play-30" % mongoVersion + ).map(_ % "test") val axiomVersion = "1.4.0" val axiomOverrides = Seq( diff --git a/project/plugins.sbt b/project/plugins.sbt index a31e7e8..db7e480 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,19 +1,14 @@ -resolvers ++= Seq( - Resolver.url("HMRC-open-artefacts-ivy", url("https://open.artefacts.tax.service.gov.uk/ivy2"))(Resolver.ivyStylePatterns), - "hmrc-releases" at "https://artefacts.tax.service.gov.uk/artifactory/hmrc-releases/", - "third-party-maven-releases" at "https://artefacts.tax.service.gov.uk/artifactory/third-party-maven-releases/", - "HMRC-open-artefacts-maven" at "https://open.artefacts.tax.service.gov.uk/maven2") - +resolvers += MavenRepository("HMRC-open-artefacts-maven2", "https://open.artefacts.tax.service.gov.uk/maven2") +resolvers += Resolver.url("HMRC-open-artefacts-ivy2", url("https://open.artefacts.tax.service.gov.uk/ivy2"))(Resolver.ivyStylePatterns) resolvers += Resolver.typesafeRepo("releases") -addSbtPlugin("uk.gov.hmrc" % "sbt-auto-build" % "3.20.0") -addSbtPlugin("uk.gov.hmrc" % "sbt-distributables" % "2.5.0") -addSbtPlugin("org.playframework" % "sbt-plugin" % "3.0.1") -addSbtPlugin("org.scoverage" % "sbt-scoverage" % "2.0.9") -addSbtPlugin("org.scalastyle" %% "scalastyle-sbt-plugin" % "1.0.0") -addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.2") -addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.11.1") - -addDependencyTreePlugin +addSbtPlugin("uk.gov.hmrc" % "sbt-auto-build" % "3.20.0") +addSbtPlugin("uk.gov.hmrc" % "sbt-distributables" % "2.5.0") +addSbtPlugin("org.playframework" % "sbt-plugin" % "3.0.1") +addSbtPlugin("org.scoverage" % "sbt-scoverage" % "2.0.9") +addSbtPlugin("org.scalastyle" % "scalastyle-sbt-plugin" % "1.0.0") +addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.2") +addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.11.1") +addSbtPlugin("ch.epfl.scala" % "sbt-bloop" % "1.5.15") ThisBuild / libraryDependencySchemes += "org.scala-lang.modules" %% "scala-xml" % VersionScheme.Always