Created
October 16, 2014 22:34
-
-
Save RobertFischer/134f97c5de9c6248a889 to your computer and use it in GitHub Desktop.
Why does one work but the other doesn't?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.specs2.mutable._ | |
import org.specs2.runner._ | |
import org.junit.runner._ | |
import play.api.test._ | |
import play.api.test.Helpers._ | |
import org.openqa.selenium.WebDriver | |
// This compiles | |
@RunWith(classOf[JUnitRunner]) | |
class IntegrationSpec extends Specification { | |
"Application" should { | |
"work from within a browser" in new WithBrowser { | |
browser.goTo("http://localhost:" + port) | |
browser.pageSource must contain("KreateLabs") | |
} | |
} | |
} | |
// This doesn't -- complains that AppBrowser needs a type variable | |
@RunWith(classOf[JUnitRunner]) | |
class IntegrationSpec2 extends Specification { | |
trait AppBrowser[WEBDRIVER <: WebDriver] extends WithBrowser[WEBDRIVER] {} | |
"Application" should { | |
"work from within a browser" in new AppBrowser { | |
browser.goTo("http://localhost:" + port) | |
browser.pageSource must contain("KreateLabs") | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A number of problems:
WithBrowser
is an abstract class. A trait can't extend an abstract class, it can only extend other traitsAppBrowser
is parameterised, when you use it, you're not declaring that parameter type (the reasonWithBrowser
works is that the default arguments for the constructor parameters declare what the type of WEBDRIVER is.