Created
August 28, 2011 12:32
-
-
Save sourcerebels/1176618 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
import sourcerebels.com.Post | |
class BootStrap { | |
def fixtureLoader | |
def init = { servletContext -> | |
environments { | |
test { | |
fixtureLoader.load { | |
build { | |
post1(Post, title: "post1") | |
post2(Post, title: "post2") | |
post3(Post, title: "post3") | |
} | |
} | |
} | |
} | |
} | |
def destroy = { | |
} | |
} |
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 pages | |
import org.codehaus.groovy.grails.plugins.webdriver.WebDriverPage | |
import org.openqa.selenium.By | |
import org.openqa.selenium.WebElement | |
import org.openqa.selenium.WebDriver | |
import org.openqa.selenium.support.FindBy | |
class HomePage extends WebDriverPage { | |
WebDriver driver | |
static expectedTitle = "sourcerebels.com" | |
static expectedURL = ~"/home" | |
def getPosts() { | |
return driver.findElements(By.className("post")) | |
} | |
} |
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 tests | |
import org.codehaus.groovy.grails.plugins.webdriver.WebDriverHelper | |
import static org.hamcrest.CoreMatchers.* | |
import static org.junit.Assert.assertThat | |
import static org.junit.matchers.JUnitMatchers.* | |
import org.junit.* | |
import static org.junit.Assert.* | |
import pages.HomePage | |
class HomeTests { | |
@Rule | |
public WebDriverHelper webdriver = new WebDriverHelper() | |
private HomePage homePage | |
@Before | |
public void openHomePage() { | |
homePage = webdriver.open('/home', HomePage.class) | |
} | |
@Test | |
public void should_retrieve_post_list() { | |
assertNotNull homePage.posts | |
assertEquals 3, homePage.posts.size | |
} | |
} |
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
<!DOCTYPE HTML> | |
<html lang="en-US"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>sourcerebels.com</title> | |
</head> | |
<body> | |
<g:if test="${postList != null}"> | |
<div id="postList"> | |
<h1>Post List</h1> | |
<g:each in="${postList}" var="post"> | |
<div class="post"> | |
<h2>${post.title}</h2> | |
${post.content} | |
</div> | |
</g:each> | |
</div> | |
</g:if> | |
</body> | |
</html> |
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
Starting functional test phase ... | |
[delete] Deleting directory /Users/edu/.grails/1.3.7/projects/sourcerebels.com/tomcat | |
Running Grails application.. | |
Server running. Browse to http://localhost:8080/sourcerebels.com | |
------------------------------------------------------- | |
Running 1 functional test... | |
Running test tests.HomeTests...--Output from should_retrieve_post_list-- | |
--Output from should_retrieve_post_list-- | |
PASSED | |
Tests Completed in 1558ms ... | |
------------------------------------------------------- | |
Tests passed: 1 | |
Tests failed: 0 | |
------------------------------------------------------- | |
Server stopped |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment