We are testing a single page app made with Java Spring, WebSockets and AngularJS. Part of our test suite consists of integration tests made with easyB. For example, here is an easyB test for "user opens the page and sees a chat window".
description 'As a user I want to access a chat window'
scenario "User can open a chat window", {
given 'User is on a right page', {
driver = new FirefoxDriver()
}
when 'a link is clicked', {
driver.get("http://localhost:8080")
}
then 'a chat window is opened', {
page = driver.getPageSource()
page.contains("panel panel-default chat-panel").shouldBe true
page.contains("chatController as chat").shouldBe true
page.contains("panel-body chat-body").shouldBe true
driver.quit()
}
}
Note that we aren't explicitly starting server components, they are magicly wired together by Spring/easyB/Maven.
Now we have modified our single page app so that the user is shown a different page depending on his/her state. We would like to test "given user of state X, page Y is shown".
given 'User has state X', {
driver = new FirefoxDriver()
sessionRepository.getMostRecentSession().setState(X); // How to do this?
}
when 'a link is clicked', {
driver.get("http://localhost:8080")
}
then 'page Y is shown', {
page = driver.getPageSource()
page.contains("bla bla").shouldBe true
driver.quit()
}
Aucun commentaire:
Enregistrer un commentaire