Esempio n. 1
0
func TestSpec(t *testing.T) {
	Convey("UserRegister", t, func() {
		var agoutiDriver *agouti.WebDriver
		var page *agouti.Page

		session, _ := mgo.Dial("localhost")

		session.DB("TESTGoNuts").DropDatabase()

		agoutiDriver = agouti.PhantomJS()

		So(agoutiDriver.Start(), ShouldBeNil)

		log.Println("Starting")

		go StartMyApp(3232, "TESTGoNuts")

		var err error
		page, err = agoutiDriver.NewPage(agouti.Browser("chrome"))
		So(err, ShouldBeNil)

		Convey("User Registration page", func() {
			Convey("when the user registration is reached", func() {
				Convey("should see the page", func() {
					So(page.Navigate("http://localhost:3232"), ShouldBeNil)

					url, _ := page.URL()
					So(url, ShouldEqual, "http://localhost:3232/")
				})
			})
		})

		Reset(func() {
			So(page.Destroy(), ShouldBeNil)
			So(agoutiDriver.Stop(), ShouldBeNil)
		})
	})
}
package integration_test

import (
	"os"
	"testing"

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
	"github.com/sclevine/agouti"
)

var (
	phantomDriver    = agouti.PhantomJS()
	chromeDriver     = agouti.ChromeDriver()
	seleniumDriver   = agouti.Selenium(agouti.Browser("firefox"))
	selendroidDriver = agouti.Selendroid("selendroid-standalone-0.15.0-with-dependencies.jar")

	headlessOnly = os.Getenv("HEADLESS_ONLY") == "true"
	mobile       = os.Getenv("MOBILE") == "true"
)

func TestIntegration(t *testing.T) {
	RegisterFailHandler(Fail)
	RunSpecs(t, "Integration Suite")
}

var _ = BeforeSuite(func() {
	Expect(phantomDriver.Start()).To(Succeed())
	if !headlessOnly {
		Expect(chromeDriver.Start()).To(Succeed())
		Expect(seleniumDriver.Start()).To(Succeed())