smoke testing with go
TRANSCRIPT
![Page 1: Smoke testing with Go](https://reader034.vdocuments.site/reader034/viewer/2022042706/589dde7c1a28ab77148b59ef/html5/thumbnails/1.jpg)
WITH GOSMOKE TESTING
![Page 2: Smoke testing with Go](https://reader034.vdocuments.site/reader034/viewer/2022042706/589dde7c1a28ab77148b59ef/html5/thumbnails/2.jpg)
GO
![Page 3: Smoke testing with Go](https://reader034.vdocuments.site/reader034/viewer/2022042706/589dde7c1a28ab77148b59ef/html5/thumbnails/3.jpg)
GO WAS CONCEIVED WHILE WAITING FOR C++ TO COMPILE
it is said that
![Page 4: Smoke testing with Go](https://reader034.vdocuments.site/reader034/viewer/2022042706/589dde7c1a28ab77148b59ef/html5/thumbnails/4.jpg)
“BORN OUT OF FRUSTRATION WITH EXISTING LANGUAGES AND
ENVIRONMENTS FOR SYSTEMS PROGRAMMING”
2007
![Page 5: Smoke testing with Go](https://reader034.vdocuments.site/reader034/viewer/2022042706/589dde7c1a28ab77148b59ef/html5/thumbnails/5.jpg)
OPEN-SOURCED BY GOOGLE 2009
![Page 6: Smoke testing with Go](https://reader034.vdocuments.site/reader034/viewer/2022042706/589dde7c1a28ab77148b59ef/html5/thumbnails/6.jpg)
COMPILED
![Page 7: Smoke testing with Go](https://reader034.vdocuments.site/reader034/viewer/2022042706/589dde7c1a28ab77148b59ef/html5/thumbnails/7.jpg)
STATICALLY-TYPED SOMETIMES THE TYPE IS INFERRED FROM THE CONTEXT
![Page 8: Smoke testing with Go](https://reader034.vdocuments.site/reader034/viewer/2022042706/589dde7c1a28ab77148b59ef/html5/thumbnails/8.jpg)
FOCUS ON READABILITY AND PERFORMANCE
DESIGNED FOR GOOGLE-SCALE CODEBASES
![Page 9: Smoke testing with Go](https://reader034.vdocuments.site/reader034/viewer/2022042706/589dde7c1a28ab77148b59ef/html5/thumbnails/9.jpg)
GARBAGE-COLLECTED
![Page 10: Smoke testing with Go](https://reader034.vdocuments.site/reader034/viewer/2022042706/589dde7c1a28ab77148b59ef/html5/thumbnails/10.jpg)
NATIVE CONCURRENCY SUPPORT COROUTINES, CHANNELS
![Page 11: Smoke testing with Go](https://reader034.vdocuments.site/reader034/viewer/2022042706/589dde7c1a28ab77148b59ef/html5/thumbnails/11.jpg)
SYNTAX ENFORCES READABILITY NO TERNARY OPERATOR
VAR++ DOES NOT RETURN VALUE
![Page 12: Smoke testing with Go](https://reader034.vdocuments.site/reader034/viewer/2022042706/589dde7c1a28ab77148b59ef/html5/thumbnails/12.jpg)
SMART DEPENDENCY LINKING FAST COMPILATION
![Page 13: Smoke testing with Go](https://reader034.vdocuments.site/reader034/viewer/2022042706/589dde7c1a28ab77148b59ef/html5/thumbnails/13.jpg)
WHAT DOES IT LOOK LIKE?
![Page 14: Smoke testing with Go](https://reader034.vdocuments.site/reader034/viewer/2022042706/589dde7c1a28ab77148b59ef/html5/thumbnails/14.jpg)
![Page 15: Smoke testing with Go](https://reader034.vdocuments.site/reader034/viewer/2022042706/589dde7c1a28ab77148b59ef/html5/thumbnails/15.jpg)
GAINING POPULARITY:
![Page 16: Smoke testing with Go](https://reader034.vdocuments.site/reader034/viewer/2022042706/589dde7c1a28ab77148b59ef/html5/thumbnails/16.jpg)
TESTING FRAMEWORKS
![Page 17: Smoke testing with Go](https://reader034.vdocuments.site/reader034/viewer/2022042706/589dde7c1a28ab77148b59ef/html5/thumbnails/17.jpg)
![Page 18: Smoke testing with Go](https://reader034.vdocuments.site/reader034/viewer/2022042706/589dde7c1a28ab77148b59ef/html5/thumbnails/18.jpg)
![Page 19: Smoke testing with Go](https://reader034.vdocuments.site/reader034/viewer/2022042706/589dde7c1a28ab77148b59ef/html5/thumbnails/19.jpg)
GINGKO TEST STRUCTURE
▸ Describe()
▸ Context()
▸ It()
▸ By()
▸ Describe()
▸ …
![Page 20: Smoke testing with Go](https://reader034.vdocuments.site/reader034/viewer/2022042706/589dde7c1a28ab77148b59ef/html5/thumbnails/20.jpg)
THE USUAL
▸ BeforeSuite()
▸ BeforeEach()
▸ AfterEach()
▸ AfterSuite()
![Page 21: Smoke testing with Go](https://reader034.vdocuments.site/reader034/viewer/2022042706/589dde7c1a28ab77148b59ef/html5/thumbnails/21.jpg)
FOCUSED SPECS
▸ FDescribe()
▸ FContext()
▸ FIt()
![Page 22: Smoke testing with Go](https://reader034.vdocuments.site/reader034/viewer/2022042706/589dde7c1a28ab77148b59ef/html5/thumbnails/22.jpg)
RUNNING TEST SUITE
go test
![Page 23: Smoke testing with Go](https://reader034.vdocuments.site/reader034/viewer/2022042706/589dde7c1a28ab77148b59ef/html5/thumbnails/23.jpg)
![Page 24: Smoke testing with Go](https://reader034.vdocuments.site/reader034/viewer/2022042706/589dde7c1a28ab77148b59ef/html5/thumbnails/24.jpg)
MAKING ASSERTIONS
‣ Expect(ACTUAL).To(Equal(EXPECTED))
‣ Expect(ACTUAL).NotTo(Equal(EXPECTED))
‣ Expect(ACTUAL).ToNot(Equal(EXPECTED))
![Page 25: Smoke testing with Go](https://reader034.vdocuments.site/reader034/viewer/2022042706/589dde7c1a28ab77148b59ef/html5/thumbnails/25.jpg)
ASSERTING EQUIVALENCE
‣ Equal(...)
‣ BeEquivalentTo(...)
‣ BeAssignableToTypeOf(...)
![Page 26: Smoke testing with Go](https://reader034.vdocuments.site/reader034/viewer/2022042706/589dde7c1a28ab77148b59ef/html5/thumbnails/26.jpg)
ASSERTING PRESENCE
‣ BeNil()
‣ BeZero()
![Page 27: Smoke testing with Go](https://reader034.vdocuments.site/reader034/viewer/2022042706/589dde7c1a28ab77148b59ef/html5/thumbnails/27.jpg)
ASSERTING TRUTHINESS
‣ BeTrue()
‣ BeFalse()
![Page 28: Smoke testing with Go](https://reader034.vdocuments.site/reader034/viewer/2022042706/589dde7c1a28ab77148b59ef/html5/thumbnails/28.jpg)
ASSERTING ON ERRORS
‣ HaveOccurred()
‣ Succeed()
‣ MatchError(...)
![Page 29: Smoke testing with Go](https://reader034.vdocuments.site/reader034/viewer/2022042706/589dde7c1a28ab77148b59ef/html5/thumbnails/29.jpg)
MAKING ASYNCHRONOUS ASSERTIONS
▸ Eventually()
▸ Consistently()
![Page 30: Smoke testing with Go](https://reader034.vdocuments.site/reader034/viewer/2022042706/589dde7c1a28ab77148b59ef/html5/thumbnails/30.jpg)
EVENTUALLY
Eventually(func() []int {
return thing.SliceImMonitoring
}, TIMEOUT, POLLING_INTERVAL).Should(HaveLen(2))
![Page 31: Smoke testing with Go](https://reader034.vdocuments.site/reader034/viewer/2022042706/589dde7c1a28ab77148b59ef/html5/thumbnails/31.jpg)
CONSISTENTLY
Consistently(func() []int {
return thing.MemoryUsage()
}).Should(BeNumerically("<", 10))
![Page 32: Smoke testing with Go](https://reader034.vdocuments.site/reader034/viewer/2022042706/589dde7c1a28ab77148b59ef/html5/thumbnails/32.jpg)
![Page 33: Smoke testing with Go](https://reader034.vdocuments.site/reader034/viewer/2022042706/589dde7c1a28ab77148b59ef/html5/thumbnails/33.jpg)
![Page 34: Smoke testing with Go](https://reader034.vdocuments.site/reader034/viewer/2022042706/589dde7c1a28ab77148b59ef/html5/thumbnails/34.jpg)
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](https://reader034.vdocuments.site/reader034/viewer/2022042706/589dde7c1a28ab77148b59ef/html5/thumbnails/35.jpg)
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](https://reader034.vdocuments.site/reader034/viewer/2022042706/589dde7c1a28ab77148b59ef/html5/thumbnails/36.jpg)
FINDING ELEMENTS
‣ page.First(“#project-toggle")
‣ page.FindByLabel(“Password")
![Page 37: Smoke testing with Go](https://reader034.vdocuments.site/reader034/viewer/2022042706/589dde7c1a28ab77148b59ef/html5/thumbnails/37.jpg)
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](https://reader034.vdocuments.site/reader034/viewer/2022042706/589dde7c1a28ab77148b59ef/html5/thumbnails/38.jpg)
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](https://reader034.vdocuments.site/reader034/viewer/2022042706/589dde7c1a28ab77148b59ef/html5/thumbnails/39.jpg)
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](https://reader034.vdocuments.site/reader034/viewer/2022042706/589dde7c1a28ab77148b59ef/html5/thumbnails/40.jpg)
OUR SETUP
![Page 41: Smoke testing with Go](https://reader034.vdocuments.site/reader034/viewer/2022042706/589dde7c1a28ab77148b59ef/html5/thumbnails/41.jpg)
DOCKER COMPOSE
SELENIUM
HEADLESS FIREFOX
GO RUNTIME
LIBRARIES
TEST SUITE
CAMATO
![Page 42: Smoke testing with Go](https://reader034.vdocuments.site/reader034/viewer/2022042706/589dde7c1a28ab77148b59ef/html5/thumbnails/42.jpg)
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](https://reader034.vdocuments.site/reader034/viewer/2022042706/589dde7c1a28ab77148b59ef/html5/thumbnails/43.jpg)
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](https://reader034.vdocuments.site/reader034/viewer/2022042706/589dde7c1a28ab77148b59ef/html5/thumbnails/44.jpg)
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](https://reader034.vdocuments.site/reader034/viewer/2022042706/589dde7c1a28ab77148b59ef/html5/thumbnails/45.jpg)
DEMO
![Page 46: Smoke testing with Go](https://reader034.vdocuments.site/reader034/viewer/2022042706/589dde7c1a28ab77148b59ef/html5/thumbnails/46.jpg)
THANKS!