Testing
“Utvecklare på Tradera pratar om testautomatisering på ert företag”
Beyond unit testing / NUnit
Kent Beck
SUnit (1989), JUnit, NUnit, xUnit
XP (1999)
My history:
KTH, First job, Agile, Tradera
Why?
Unit Tests => Code Quality
Testing
“Utvecklare på Tradera pratar om testautomatisering på ert företag”
Beyond unit testing / NUnit
Kent Beck
SUnit (1989), JUnit, NUnit, xUnit
XP (1999)
My history:
KTH, First job, Agile, Tradera
Why?
Unit Tests => Code Quality
Content
Theory:
Practice:
Bonus:
Test-Driven Development
Beyond unit testing
Arrange, Act, Assert
Red, Green, Refactor
Integration Testing
Why?
TDD => Code Design
Building the thing right,
Building the right thing
Behavior-Driven Development
Beyond TDD
Desired behavior
(Business)
Natural language
Communication and collaboration
User story, Acceptance criteria
Understand why a test fails
Test runner, test result
Given-When-Then
When-Should
Why?
BDD => Communication / Collaboration
Stack
When empty
should have no elements
should throw an exception when calling peek
should throw an exception when calling pop
When not empty
should not remove the top element when calling peek
should remove the top element when calling pop
should return the top element when calling peek
should return the top element when calling pop
Specification By Example
Shared Understanding
Living Documentation
Single source of truth
Executable specifications
Illustrating requirements using examples
Cucumber
Gherkin
Three Amigos; devs, testers, biz
User story, “promise for a conversation”
DSL
Gojko Adzic
Books
Empty stack
Given an empty stack
Then it has no elements
And it throws an exception when calling pop
And it throws an exception when calling peek
Non empty stack
Given a non empty stack
When calling peek
Then it returns the top element
But it does not remove the top element
When calling pop
Then it returns the top element
And it removes the top element
Requirements
EARS
Frameworks
Machine.Specifications (MSpec)
SpecFlow
https://conductofcode.io/post/bdd-frameworks-for-dotnet-csharp/
Auto-Mocking
Refactoring ctor signatures
Not testing all dependencies
Less setup code
https://github.com/machine/machine.fakes
Should
Assert:
Less readable
Wrong order of parameters; expected, actual
Extension methods
Fluent?
https://www.nuget.org/packages?q=Should
Browser
Selenium
Puppeteer
AJAX, Waits
async / await
https://github.com/kblok/puppeteer-sharp
Page Objects
http://martinfowler.com/bliki/PageObject.html
https://github.com/SeleniumHQ/selenium/wiki/PageObjects
My Projects
https://github.com/hlaueriksson/puppeteer-sharp-contrib
https://github.com/hlaueriksson/LoFuUnit
Tradera
Unit Tests => Code Quality
TDD => Code Design
BDD => Communication / Collaboration
CI/CD/DevOps => Confidence / Speed / Collective Ownership / Remove Bottlenecks
GitLab, Merge Requests
TeamCity, Continuous Integration
Hubot, Release Queue
AsimovDeploy, Distributed Deployment, Verify Steps
LogViewer, Centralized Logging
*.mp4
Thanks!
Questions?
Resources