Last active
August 29, 2015 14:01
-
-
Save sebnozzi/4a88d60adc809f2f2e3c to your computer and use it in GitHub Desktop.
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
package org.hyperscala.hello | |
import org.scalatest.WordSpec | |
import org.scalatest.Matchers | |
import org.scalatest.BeforeAndAfter | |
class HelloPageTest extends WordSpec with Matchers with BeforeAndAfter { | |
"HelloPage" when { | |
"when rendered" should { | |
"have Hello, World!" in { | |
val page = new HelloPage() | |
// what/how to test here? | |
} | |
} | |
} | |
} |
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
package org.hyperscala.hello | |
import org.scalatest.WordSpec | |
import org.scalatest.Matchers | |
import org.scalatest.BeforeAndAfter | |
import org.hyperscala.html._ | |
class HelloSiteDirectTest extends WordSpec with Matchers with BeforeAndAfter { | |
before { | |
System.setProperty("port", "3333") | |
// start application | |
HelloSite.main(Array.empty[String]) | |
} | |
after { | |
HelloSite.dispose() // end application | |
} | |
"HelloSite" when { | |
"showing the index page" should { | |
"have Hello, World!" in { | |
val page = HelloSite.index | |
// how / what to test here? | |
} | |
} | |
} | |
} |
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
package org.hyperscala.hello | |
import org.scalatest.WordSpec | |
import org.scalatest.Matchers | |
import org.scalatest.BeforeAndAfter | |
import org.scalatest.selenium.WebBrowser | |
import org.openqa.selenium.htmlunit.HtmlUnitDriver | |
import org.openqa.selenium.WebDriver | |
class HelloSiteSeleniumTest extends WordSpec with Matchers with BeforeAndAfter with WebBrowser { | |
implicit val webDriver: WebDriver = new HtmlUnitDriver | |
before { | |
System.setProperty("port", "3333") | |
// start application | |
HelloSite.main(Array.empty[String]) | |
} | |
after { | |
quit() // browser | |
HelloSite.dispose() // end application | |
} | |
object HomePage extends org.scalatest.selenium.Page { | |
val url = "http://localhost:3333/" | |
} | |
"HelloSite" when { | |
"showing the index page" should { | |
"have Hello, World!" in { | |
go to HomePage | |
find(tagName("body")) map { body => | |
body.text should be("Hello, World!") | |
} getOrElse fail("Element not found") | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
As you can see, I managed to test the HelloSite application using Selenium.
What it's not clear to me is how to test with the other approaches, and what makes sense to test...