Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pre-scala 2.13: Update scalatest, scalacheck and scalatestplus.play #24927

Merged
merged 2 commits into from
May 5, 2022

Conversation

ioannakok
Copy link
Contributor

@ioannakok ioannakok commented Apr 22, 2022

Closes #24933

As part of the upgrade to Scala 2.13 these dependencies are now compatible with both 2.12 and 2.13

What does this change?

Dependencies

In Dependencies.scala:

  • Updates / Adds the following dependencies:
Dependency Before After
"org.scalacheck" %% "scalacheck" % 1.13.5 1.16.0
"org.scalatest" %% "scalatest" 3.0.4 3.2.11
"org.scalatestplus.play" %% "scalatestplus-play" 3.1.1 5.1.0
"org.scalatestplus" %% "mockito-3-4" "3.3.0.0-SNAP3"
"org.scalatestplus" %% "scalacheck-1-15" "3.2.11.0"
  • org.scalatestplus.mockito-3-4 had to be added to have access to MockitoSugar. It is now imported from org.scalatestplus.mockito.MockitoSugar

  • org.scalatestplus.scalacheck-1-15 had to be added because instead of using GeneratorDrivenPropertyChecks we are now using ScalaCheckDrivenPropertyChecks. The first was removed (scalatest recommendation here: GeneratorDrivenPropertyChecks and PropertyChecks are Gone in 3.1.0 scalatest/scalatest#1735). The second is now imported from org.scalatestplus.scalacheck.ScalaCheckDrivenPropertyChecks (e.g. common/test/layout/slices/DynamicContainerTest.scala).

Renaming / Re-importing

After the above dependencies are upgraded / added, the following changes had to be made in the test files:

Class Renamed to Re-imported from
WordSpec AnyWordSpec org.scalatest.wordspec.AnyWordSpec
WordSpecLike AnyWordSpecLike org.scalatest.wordspec.AnyWordSpecLike
FlatSpec AnyFlatSpec org.scalatest.flatspec.AnyFlatSpec
FreeSpec AnyFreeSpec org.scalatest.freespec.AnyFreeSpec
FeatureSpec AnyFeatureSpec org.scalatest.featurespec.AnyFeatureSpec
FlatSpecLike AnyFlatSpecLike org.scalatest.flatspec.AnyFlatSpecLike
FunSuite AnyFunSuite org.scalatest.funsuite.AnyFunSuite
WordSpec AnyWordSpec org.scalatest.wordspec.AnyWordSpec
path.FreeSpec PathAnyFreeSpec org.scalatest.freespec.PathAnyFreeSpec
Matchers Same name org.scalatest.matchers.should.Matchers

because the previous classes were renamed in scalatest:3.1.0 (https://www.scalatest.org/release_notes/3.1.0) and removed in scalatest:3.2.0 (https://www.scalatest.org/release_notes/3.2.0).

Deprecated functions

Remove overriding the port in test suites that implement SingleServerSuite

Overriding the port was introduced by this PR: #14736. However, in the new scalatestplus-play version it cannot be overriden as it's final: https://github.com/playframework/scalatestplus-play/blob/main/module/src/main/scala/org/scalatestplus/play/ServerProvider.scala#L48. At the moment, there does not seem to be any other option for configuring the port: playframework/scalatestplus-play#123

Test are passing after this bit of code gets removed. There seems to be automatic allocation of ports (in a range of 24000 -2^16) so it seems reasonable to not replace the port override with new code that configures it.

Does this change need to be reproduced in dotcom-rendering ?

  • No
  • Yes (please indicate your plans for DCR Implementation)

Screenshots

What is the value of this and can you measure success?

Checklist

Does this affect other platforms?

  • AMP
  • Apps
  • Other (please specify)

Does this affect GLabs Paid Content Pages? Should it have support for Paid Content?

  • No
  • Yes (please give details)

Does this change break ad-free?

  • No
  • It did, but tests caught it and I fixed it
  • It did, but there was no test coverage so I added that then fixed it

Does this change update the version of CAPI we're using?

Accessibility test checklist

Tested

  • Locally
  • On CODE (optional)

@ioannakok ioannakok requested a review from a team as a code owner April 22, 2022 11:38
@ioannakok ioannakok added the Scala 2.13 See https://github.com/guardian/maintaining-scala-projects/issues/2 label Apr 22, 2022
@ioannakok ioannakok requested a review from a team as a code owner April 22, 2022 16:38
@ioannakok ioannakok marked this pull request as draft April 25, 2022 11:36
@@ -13,5 +14,7 @@ class AdminTestSuite
new controllers.admin.DeploysControllerTest,
)
with SingleServerSuite {
override lazy val port: Int = 19015

override implicit lazy val portNumber: PortNumber = PortNumber(19015)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have to make this change because this test suite implements ServerProvider (via SingleServerSuite) and port is final in the new version of scalatestplus-play so it cannot be overriden: https://github.com/playframework/scalatestplus-play/blob/main/module/src/main/scala/org/scalatestplus/play/ServerProvider.scala#L48.

@@ -45,5 +45,7 @@ class ApplicationsTestSuite
new InteractivePickerTest,
)
with SingleServerSuite {
override lazy val port: Int = 19003

// override implicit lazy val portNumber: PortNumber = PortNumber(19003)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was expecting this change to be working like it does for other test suites, e.g. admin/test/package.scala but all tests are passing only if it's completely removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Example of tests failing: https://github.com/guardian/frontend/blob/main/common/test/model/ContentTest.scala. They seem to be Selenium tests

@ioannakok ioannakok force-pushed the update-scalatest branch 3 times, most recently from 66f4e8e to a58c949 Compare May 3, 2022 14:21
Copy link
Member

@rtyley rtyley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome!

@ioannakok ioannakok marked this pull request as ready for review May 3, 2022 15:29
@ioannakok ioannakok changed the title Update scalatest, scalacheck and scalatestplus.play Pre-scala 2.13: Update scalatest, scalacheck and scalatestplus.play May 3, 2022
ioannakok and others added 2 commits May 5, 2022 10:59
As part of the upgrade to Scala 2.13 these dependecies are now compatible with both
…lus.play versions

Remove overriding setting specific portNumber from test suites that implement SingleServerSuite because there seems to be automatic allocation of ports

Co-authored-by: Olly Namey <olly.namey@guardian.co.uk>
Co-authored-by: Roberto Tyley <roberto.tyley@guardian.co.uk>
@ioannakok ioannakok merged commit 6f2d578 into main May 5, 2022
@ioannakok ioannakok deleted the update-scalatest branch May 5, 2022 10:36
@prout-bot prout-bot added Pending-on-PROD Seen-on-PROD and removed Scala 2.13 See https://github.com/guardian/maintaining-scala-projects/issues/2 Pending-on-PROD labels May 5, 2022
@prout-bot
Copy link
Collaborator

Seen on PROD (merged by @ioannakok 13 minutes and 42 seconds ago)

@ioannakok ioannakok mentioned this pull request Aug 23, 2022
2 tasks
@rtyley rtyley added the Scala 2.13 See https://github.com/guardian/maintaining-scala-projects/issues/2 label Feb 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Scala 2.13 See https://github.com/guardian/maintaining-scala-projects/issues/2 Seen-on-PROD
Projects
None yet
Development

Successfully merging this pull request may close these issues.

scalatest, scalacheck, scalatest-plus
3 participants