smoke testing with go

46
WITH GO SMOKE TESTING

Upload: oleksiy-holubyev

Post on 10-Feb-2017

268 views

Category:

Documents


3 download

TRANSCRIPT

Page 1: Smoke testing with Go

WITH GOSMOKE TESTING

Page 2: Smoke testing with Go

GO

Page 3: Smoke testing with Go

GO WAS CONCEIVED WHILE WAITING FOR C++ TO COMPILE

it is said that

Page 4: Smoke testing with Go

“BORN OUT OF FRUSTRATION WITH EXISTING LANGUAGES AND

ENVIRONMENTS FOR SYSTEMS PROGRAMMING”

2007

Page 5: Smoke testing with Go

OPEN-SOURCED BY GOOGLE 2009

Page 6: Smoke testing with Go

COMPILED

Page 7: Smoke testing with Go

STATICALLY-TYPED SOMETIMES THE TYPE IS INFERRED FROM THE CONTEXT

Page 8: Smoke testing with Go

FOCUS ON READABILITY AND PERFORMANCE

DESIGNED FOR GOOGLE-SCALE CODEBASES

Page 9: Smoke testing with Go

GARBAGE-COLLECTED

Page 10: Smoke testing with Go

NATIVE CONCURRENCY SUPPORT COROUTINES, CHANNELS

Page 11: Smoke testing with Go

SYNTAX ENFORCES READABILITY NO TERNARY OPERATOR

VAR++ DOES NOT RETURN VALUE

Page 12: Smoke testing with Go

SMART DEPENDENCY LINKING FAST COMPILATION

Page 13: Smoke testing with Go

WHAT DOES IT LOOK LIKE?

Page 14: Smoke testing with Go
Page 15: Smoke testing with Go

GAINING POPULARITY:

Page 16: Smoke testing with Go

TESTING FRAMEWORKS

Page 17: Smoke testing with Go
Page 18: Smoke testing with Go
Page 19: Smoke testing with Go

GINGKO TEST STRUCTURE

▸ Describe()

▸ Context()

▸ It()

▸ By()

▸ Describe()

▸ …

Page 20: Smoke testing with Go

THE USUAL

▸ BeforeSuite()

▸ BeforeEach()

▸ AfterEach()

▸ AfterSuite()

Page 21: Smoke testing with Go

FOCUSED SPECS

▸ FDescribe()

▸ FContext()

▸ FIt()

Page 22: Smoke testing with Go

RUNNING TEST SUITE

go test

Page 23: Smoke testing with Go
Page 24: Smoke testing with Go

MAKING ASSERTIONS

‣ Expect(ACTUAL).To(Equal(EXPECTED))

‣ Expect(ACTUAL).NotTo(Equal(EXPECTED))

‣ Expect(ACTUAL).ToNot(Equal(EXPECTED))

Page 25: Smoke testing with Go

ASSERTING EQUIVALENCE

‣ Equal(...)

‣ BeEquivalentTo(...)

‣ BeAssignableToTypeOf(...)

Page 26: Smoke testing with Go

ASSERTING PRESENCE

‣ BeNil()

‣ BeZero()

Page 27: Smoke testing with Go

ASSERTING TRUTHINESS

‣ BeTrue()

‣ BeFalse()

Page 28: Smoke testing with Go

ASSERTING ON ERRORS

‣ HaveOccurred()

‣ Succeed()

‣ MatchError(...)

Page 29: Smoke testing with Go

MAKING ASYNCHRONOUS ASSERTIONS

▸ Eventually()

▸ Consistently()

Page 30: Smoke testing with Go

EVENTUALLY

Eventually(func() []int {

return thing.SliceImMonitoring

}, TIMEOUT, POLLING_INTERVAL).Should(HaveLen(2))

Page 31: Smoke testing with Go

CONSISTENTLY

Consistently(func() []int {

return thing.MemoryUsage()

}).Should(BeNumerically("<", 10))

Page 32: Smoke testing with Go
Page 33: Smoke testing with Go
Page 34: Smoke testing with Go

PROCESS

‣ Connect to the web driver

‣ Create page object

‣ Find / select elements on the page to interact with

‣ Interact (click, fill in text, submit form, …)

‣ Make assertions about the expected result

‣ Destroy page object

Page 35: Smoke testing with Go

CONNECTING TO THE WEB DRIVER

var err error

capabilities := agouti.NewCapabilities().Browser("firefox").Platform("linux").With("javascriptEnabled")

page, err = agouti.NewPage("http://selenium:4444/wd/hub", agouti.Desired(capabilities))

Expect(err).NotTo(HaveOccurred())

page.Size(1360, 768)

Page 36: Smoke testing with Go

FINDING ELEMENTS

‣ page.First(“#project-toggle")

‣ page.FindByLabel(“Password")

Page 37: Smoke testing with Go

MORE FINDERS

‣ FindByButton(text string) *Selection

‣ FindByLabel(text string) *Selection

‣ FindByLink(text string) *Selection

‣ FindByName(name string) *Selection

‣ FindByXPath(selector string) *Selection

‣ and many more…

Page 38: Smoke testing with Go

THINGS TO DO WITH THE PAGE‣ GetCookies() ([]*http.Cookie, error)

‣ Navigate(url string) error

‣ RunScript(body string, arguments map[string]interface{}, result interface{}) error

‣ Screenshot(filename string) error

‣ SetCookie(cookie *http.Cookie) error

‣ Size(width, height int) error

‣ and so on…

Page 39: Smoke testing with Go

THINGS TO DO WITH THE SELECTION

‣ Check() error

‣ Click() error

‣ Fill(text string) error

‣ Submit() error

‣ UploadFile(filename string) error

‣ FlickFinger(xOffset, yOffset int, speed uint) error

‣ and so on…

Page 40: Smoke testing with Go

OUR SETUP

Page 41: Smoke testing with Go

DOCKER COMPOSE

SELENIUM

HEADLESS FIREFOX

GO RUNTIME

LIBRARIES

TEST SUITE

CAMATO

Page 42: Smoke testing with Go

ENVIRONMENT VARIABLES

‣ ENV: {staging, review, integration, www}

‣ which server to test against

‣ SCREENSHOT: {yes, no}

‣ whether or not to record screenshots

Page 43: Smoke testing with Go

IN DOCKER-COMPOSE.YML

kitten:

<<: *smoketests

command: go test -test.timeout 15m -ginkgo.progress -ginkgo.v -ginkgo.focus Kitten

campaign_management:

<<: *smoketests

command: go test -test.timeout 15m -ginkgo.progress -ginkgo.v -ginkgo.focus Campaign

Page 44: Smoke testing with Go

FROM THE COMMAND LINE

docker-compose run -e ENV=staging -e SCREENSHOT=yes all

docker-compose run -e ENV=staging -e SCREENSHOT=yes kitten

docker-compose run -e ENV=staging -e SCREENSHOT=yes campaign_management

Page 45: Smoke testing with Go

DEMO

Page 46: Smoke testing with Go

THANKS!