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

ScalaTest 3.2 #353

Merged
merged 18 commits into from
Oct 7, 2022
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
f0b67d3
First version that works with ScalaTest 3.2.10, had to drop phantom j…
cheeseng Apr 15, 2022
9eafdb5
Got the tests to go green when run in Firefox and Chrome.
cheeseng Apr 16, 2022
938fb51
Changed firefoxProfile, chromeOptions, firefoxProfile in AllBrowsersP…
cheeseng Apr 17, 2022
483ba2c
Merge branch 'main' of https://github.com/playframework/scalatestplus…
cheeseng Apr 26, 2022
dc882ee
Updated to use ScalaTest 3.2.12.
cheeseng Apr 27, 2022
de6946c
Adjusted according to @mkurz's comments.
cheeseng Apr 28, 2022
a725191
Merge branch 'main' of https://github.com/playframework/scalatestplus…
cheeseng May 25, 2022
1d1c55d
Updated to use scalatest+selenium 3.2.12.1.
cheeseng May 25, 2022
6f3d2de
Added support for the newly added Edge browser.
cheeseng May 25, 2022
cb0da65
Merge branch 'main' of https://github.com/playframework/scalatestplus…
cheeseng Jul 9, 2022
ebd1b6f
Trying to add ci.yml.
cheeseng Jul 13, 2022
0a73c3b
Added git fetch --unshallow to ci.yml.
cheeseng Jul 14, 2022
d5f1b21
Updated version of scalatest to 3.2.13, selenium 4.2.2, htmlunit 3.62…
cheeseng Aug 1, 2022
c3ca97e
Bumped selenium version up to 4.4.0, and htmlunit version to 3.64.0.
cheeseng Sep 1, 2022
80c20ee
Merge branch 'main' of https://github.com/playframework/scalatestplus…
cheeseng Sep 17, 2022
0a38abc
Added IntegrationPatient to MixedFixturesWsScalaTestClientSpec and On…
cheeseng Sep 17, 2022
16ffbec
Merge branch 'main' into feature-scalatest-3.2
mkurz Oct 6, 2022
ad9dfda
Key not needed anymore
mkurz Oct 6, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ project/project/
project/target/
target/
.idea
.bsp/
cheeseng marked this conversation as resolved.
Show resolved Hide resolved
33 changes: 19 additions & 14 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,21 @@
* limitations under the License.
*/
import com.typesafe.tools.mima.core._
import sbt.util._
import sbt.util.{Level => _, _}

import scala.sys.process._
import sbt.io.Path._
import interplay.ScalaVersions._

import play.core.PlayVersion

val SeleniumVersion = "3.141.59"
val HtmlUnitVersion = "2.60.0"
val PhantomJsDriverVersion = "1.5.0"
val SeleniumVersion = "4.1.1"
val HtmlUnitVersion = "3.56.0"
val MockitoVersion = "3.4.6"
val CssParserVersion = "1.6.0"
val ScalatestVersion = "3.1.4"
val ScalatestSeleniumVersion = "3.1.4.0"
val ScalatestMockitoVersion = "3.2.10.0"
val ScalatestVersion = "3.2.12"
val ScalatestSeleniumVersion = "3.2.12.0"
val ScalatestMockitoVersion = "3.2.12.0"

ThisBuild / playBuildRepoName := "scalatestplus-play"
ThisBuild / resolvers += Resolver.sonatypeRepo("releases")
Expand Down Expand Up @@ -102,17 +101,23 @@ lazy val `scalatestplus-play` = project
mimaSettings,
organization := "org.scalatestplus.play",
libraryDependencies ++= Seq(
// Note: It seems like the only jackson version that works with all play, play-ws, play-json and selenium is 2.11.4.
// play will bring in older version of selenium as well, so need excluding and let scalatest+selenium brings in the newer version.4
Copy link
Member

Choose a reason for hiding this comment

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

If I remember correctly, this is because new selenium versions do not support Java 8 anymore, but right now Play still is build with Java 8.
However we are going to drop Java 8 very soon, so that would resolve that problem.

ws,
akkaHttpServer % Test,
"com.typesafe.play" %% "play-test" % PlayVersion.current,
"com.typesafe.play" %% "play-test" % PlayVersion.current exclude ("com.fasterxml.jackson.core", "jackson-core")
exclude ("com.fasterxml.jackson.core", "jackson-databind")
exclude ("org.seleniumhq.selenium", "htmlunit-driver")
exclude ("org.seleniumhq.selenium", "selenium-api")
exclude ("org.seleniumhq.selenium", "selenium-support")
exclude ("org.seleniumhq.selenium", "selenium-firefox-driver")
exclude ("org.seleniumhq.selenium", "selenium-remote-driver"),
"org.scalatest" %% "scalatest" % ScalatestVersion,
"org.scalatestplus" %% "mockito-3-4" % ScalatestMockitoVersion,
"org.scalatestplus" %% "selenium-3-141" % ScalatestSeleniumVersion,
"org.seleniumhq.selenium" % "selenium-java" % SeleniumVersion,
"org.seleniumhq.selenium" % "htmlunit-driver" % HtmlUnitVersion,
"net.sourceforge.htmlunit" % "htmlunit-cssparser" % CssParserVersion,
"com.codeborne" % "phantomjsdriver" % PhantomJsDriverVersion
"org.scalatestplus" %% "mockito-4-5" % ScalatestMockitoVersion,
"org.scalatestplus" %% "selenium-4-1" % ScalatestSeleniumVersion exclude ("com.fasterxml.jackson.core", "jackson-core")
exclude ("com.fasterxml.jackson.core", "jackson-databind"),
),
evictionErrorLevel := Level.Info,
Compile / doc / scalacOptions := Seq("-doc-title", "ScalaTest + Play, " + releaseVersion),
pomExtra := PomExtra
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,31 +194,31 @@ trait AllBrowsersPerSuite extends TestSuiteMixin with WebBrowser with Eventually
*
* @return an instance of `FirefoxProfile`
*/
protected lazy val firefoxProfile: FirefoxProfile = FirefoxFactory.firefoxProfile
protected def firefoxProfile: FirefoxProfile = FirefoxFactory.firefoxProfile

/**
* Method to provide `FirefoxOptions` for creating `FirefoxDriver`, you can override this method to
* provide a customized instance of `FirefoxOptions`
*
* @return an instance of `FirefoxOptions`
*/
protected lazy val firefoxOptions: FirefoxOptions = FirefoxFactory.firefoxOptions
protected def firefoxOptions: FirefoxOptions = FirefoxFactory.firefoxOptions

/**
* Method to provide `ChromeOptions` for creating `ChromeDriver`, you can override this method to
* provide a customized instance of `ChromeOptions`
*
* @return an instance of `ChromeOptions`
*/
protected lazy val chromeOptions: ChromeOptions = ChromeFactory.chromeOptions
protected def chromeOptions: ChromeOptions = ChromeFactory.chromeOptions

/**
* Method to provide `ChromeDriverService` for creating `ChromeDriver`, you can override this method to
* provide a customized instance of `ChromeDriverService`
*
* @return an instance of `ChromeDriverService`
*/
protected lazy val chromeDriverService: ChromeDriverService = ChromeFactory.chromeDriverService
protected def chromeDriverService: ChromeDriverService = ChromeFactory.chromeDriverService

/**
* Info for available browsers. Override to add in custom `BrowserInfo` implementations.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import BrowserFactory.GrumpyDriver
import BrowserFactory.UnavailableDriver
import BrowserFactory.UnneededDriver
import BrowserFactory.UninitializedDriver
import org.openqa.selenium.chrome.{ChromeDriverService, ChromeOptions}
import org.openqa.selenium.firefox.FirefoxProfile
import org.scalatestplus.selenium.WebBrowser

Expand Down Expand Up @@ -191,13 +192,29 @@ trait AllBrowsersPerTest extends TestSuiteMixin with WebBrowser with Eventually
*
* @return an instance of `FirefoxProfile`
*/
protected lazy val firefoxProfile: FirefoxProfile = new FirefoxProfile
protected def firefoxProfile: FirefoxProfile = new FirefoxProfile

/**
* Method to provide `ChromeOptions` for creating `ChromeDriver`, you can override this method to
* provide a customized instance of `ChromeOptions`
*
* @return an instance of `ChromeOptions`
*/
protected def chromeOptions: ChromeOptions = ChromeFactory.chromeOptions

/**
* Method to provide `ChromeDriverService` for creating `ChromeDriver`, you can override this method to
* provide a customized instance of `ChromeDriverService`
*
* @return an instance of `ChromeDriverService`
*/
protected def chromeDriverService: ChromeDriverService = ChromeFactory.chromeDriverService

/**
* Info for available browsers. Override to add in custom `BrowserInfo` implementations.
*/
protected lazy val browsers: IndexedSeq[BrowserInfo] =
Vector(FirefoxInfo(firefoxProfile), SafariInfo, InternetExplorerInfo, ChromeInfo(), HtmlUnitInfo(true))
protected def browsers: IndexedSeq[BrowserInfo] =
Vector(FirefoxInfo(firefoxProfile), SafariInfo, InternetExplorerInfo, ChromeInfo(chromeDriverService, chromeOptions), HtmlUnitInfo(true))

private var privateWebDriver: WebDriver = UninitializedDriver

Expand Down
30 changes: 0 additions & 30 deletions module/src/main/scala/org/scalatestplus/play/BrowserInfo.scala
Original file line number Diff line number Diff line change
Expand Up @@ -185,33 +185,3 @@ case class HtmlUnitInfo(enableJavascript: Boolean)
*/
def createWebDriver(): WebDriver = HtmlUnitFactory.createWebDriver(enableJavascript)
}

/**
* PhantomJS browser info, which encapsulates the browser name, `"[PhantomJS]"`; tag name, `org.scalatest.tags.PhantomJS`; and a factory method that produces a Selenium [[org.openqa.selenium.phantomjs.PhantomJSDriver]].
*
* This class's superclass, `BrowserInfo`, is used by [[org.scalatestplus.play.AllBrowsersPerSuite AllBrowsersPerSuite]] and
* [[org.scalatestplus.play.AllBrowsersPerTest AllBrowsersPerTest]]: an `IndexedSeq[BrowserInfo]` is returned
* from the `browsers` field of these traits to specify the browsers to share between tests.
* When tests are registered, `AllBrowsersPerSuite` and `AllBrowsersPerTest` use the browser name to ensure the tests shared by multiple browsers
* have unique names (the name of each shared test is appended with a browser name). When the tests run, these traits
* use the `BrowserInfo`'s factory method to create `WebDriver`s as needed.
* The `AllBrowsersPerSuite` and `AllBrowsersPerTest` traits use the tag name to automatically tag any tests that use
* a particular `WebDriver` with the appropriate tag so that tests can be dynamically filtered by the browser the use.
*
* @param phantomCapabilities the [[DesiredCapabilities]] to use when creating new [[org.openqa.selenium.phantomjs.PhantomJSDriver]]
* in the `createWebDriver` factory method.
*/
@deprecated("PhantomJS is no longer actively developed, and support will eventually be dropped", "4.0.0")
case class PhantomJSInfo(phantomCapabilities: DesiredCapabilities = DesiredCapabilities.phantomjs())
extends BrowserInfo("[PhantomJS]", "org.scalatest.tags.PhantomJSBrowser") {

/**
* Creates a new instance of a Selenium [[org.openqa.selenium.phantomjs.PhantomJSDriver]], or returns a [[org.scalatestplus.play.BrowserFactory.UnavailableDriver BrowserFactory.UnavailableDriver]] that includes
* the exception that indicates Firefox was not supported on the host platform and an appropriate
* error message.
*
* @return an new instance of a Selenium [[org.openqa.selenium.phantomjs.PhantomJSDriver]], or a [[org.scalatestplus.play.BrowserFactory.UnavailableDriver BrowserFactory.UnavailableDriver]] if PhantomJS
* was not available on the host platform.
*/
def createWebDriver(): WebDriver = PhantomJSFactory.createWebDriver(phantomCapabilities)
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ trait ChromeFactory extends BrowserFactory {
/**
* Default [[ChromeDriverService]] used to create a [[ChromeDriver]] instance. Override to provide different service.
*/
lazy val chromeDriverService: ChromeDriverService = ChromeDriverService.createDefaultService()
def chromeDriverService: ChromeDriverService = ChromeDriverService.createDefaultService()

/**
* Creates a new instance of a Selenium [[ChromeDriver]], or returns a [[BrowserFactory.UnavailableDriver]] that
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ class AllBrowsersPerTestBehaviorSpec extends AnyWordSpec {

"run only Chrome and non-browser tests when browsers is overridden to include ChromeInfo only" in {
class ChromeTestSpec extends TestSpec {
override lazy val browsers: IndexedSeq[BrowserInfo] =
override def browsers: IndexedSeq[BrowserInfo] =
Vector(ChromeInfo())
}

Expand Down

This file was deleted.

2 changes: 2 additions & 0 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@ addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.6")
addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "1.1.0")

addSbtPlugin("com.dwijnand" % "sbt-dynver" % "4.1.1")

addDependencyTreePlugin
cheeseng marked this conversation as resolved.
Show resolved Hide resolved