Upload
yasha-kramarenko
View
894
Download
0
Embed Size (px)
Citation preview
You don’t need Automation Engineer!
@yashaka
Automation is hard, isn’t it?
It isn’t:p
It isn’t:p
(at least WEB UI)
if you know how to “cook” it ;)It isn’t:p
But no rush:)
Let’s start from beginning…
Product
Use cases (draft)Tree
shleep
eat
run
hang
Holes
shleep
eat
run
During All activities:
sh-shispering
Special Cases:
GIVEN shleepingWHEN 2 meters to somebody
THEN become invisible
Transitions:
tree > holes
tree < holes
Choosing high priority functionalityTree
shleep *
eat *
run *
hang *
Holes
shleep *
eat *
run *
During All activities:
sh-shispering
Special Cases: *
GIVEN shleepingWHEN 2 meters to somebody
THEN become invisible
Transitions:
tree > holes *
tree < holes *
To implement first & fastTree
shleep *
eat *
run *
hang *
Holes
shleep *
eat *
run *
Transitions:
tree > holes *
tree < holes *
Scenario (End to End)go to hole
run
go to tree
hang
eat
go to hole
shleep
Tracking coverageTree
shleep
eat e
run
hang e
Holes
shleep e
eat
run e
During All activities:
sh-shispering
Special Cases:
GIVEN shleepingWHEN 2 meters to somebody
THEN become invisible
Transitions:
holes > tree e
holes < tree e
A bit messy?
be DRY ;)
Improve visibility
Actions\Context Holes Tree sh-shispering?
run !!e ! !
hang - !!e !
eat !! !!e !
shleep !!e !! !
- shleep invisible ? !! !
Transitions: holes > trees e holes < trees e
Actions\Context Holes Tree sh-shispering?
run !!e ! !
hang - !!e !
eat !! !!e !
shleep !!e !! !
- shleep invisible ? !! !
Transitions: holes > trees e holes < trees e
hole in coverage
E2Ego to hole
run
go to tree
hang
eat
go to hole
shleep
1-Feature test
go to tree
shleep invisible
Finalise smoke coverage
E2Ego to hole
run
go to tree
hang
eat
go to hole
shleep
1-Feature test
go to tree
shleep invisible
assert shispering
Use possibilities to improve coverage
Actions\Context Holes Tree sh-shispering?
run !!e ! !
hang - !!e !
eat !! !!e !
shleep !!e !! !
- shleep invisible ? !!f !f
Transitions: holes > trees e holes < trees e
Done with Smoke? - Proceed to Full Acceptance with FT
Actions\Context Holes Tree sh-shispering?
run !!e !f !f
hang - !!e !e
eat !!f !!e !f
shleep !!e !!f !f
- shleep invisible ? !!f !f
Coverage tips: Yes
Functional Use Cases
High priority,
(user will definitely do on regular basis)
Coverage tips: No
low-priority checks
“different values” checks
Actions\Context Holes Tree sh-shispering?
run !!e ! !
hang - !!e !
eat !! !!e !
shleep !!e !! !
- shleep invisible ? !!e !
Transitions: holes > trees e holes < trees e
No low-priority checksActions\Context Holes Tree sh-shispering?
run !!e ! !
hang - !!e !
eat !! !!e !
shleep !!e !! !
- shleep invisible ? !!e !
Actions\Context Holes Tree sh-shispering?
run !!e ! !- fast
- slow ? ?
hang - !!e !- low
- high ? ?
eat !! !!e !- much
- a bit ? ?
shleep !!e !! !
- shleep invisible ? !!e !
No “different values” checks
Actions\Context Holes Tree sh-shispering?
run !!e ! !- fast
- slowhang - !!e !
- low- high
eat !! !!e !- much
- a bitshleep !!e !! !
- shleep invisible ? !!e !
No “different values” checks
different variations of same “function”
Should be covered on “unit testing” level
different variations of same “function”
- fast- slow
- low- high
- much- a bit
(giving the same “user flow”)
We are here => => Only:functional
high priority use cases
different variations
of same “function”Here =>
Avoid =>move
additional requirements, like “different kind of names
for entities”, “function variations”, etc…
<= to
=> from
Where is code ?
Keep calm:)
From
To
Actions
run, hang, eat, sleep create, edit, delete, toggle, toggle all
Contexts
holes, treesfitlers:
all, active, completed
The same ;)
go to hole
run
go to tree
hang
eat
go to hole
shleep
Scenario (End to End)
Scenario (End to End)given at todomvc
add "a"
toggle "a"
filter active
filter completed
edit "a" to "a edited"
toggle "a edited"
…
Add expected resultsgiven at todomvc
add "a"
toggle "a"
filter active assert no tasks
filter completed
edit "a" to "a edited"
toggle "a edited" assert no tasks
…
Implicit checks are ok in “nearest steps”given at todomvc
add "a"
toggle "a"
filter activeassert no tasks
filter completed
edit "a" to "a edited"
toggle "a edited"assert no tasks
…
Demo
Let’s start coding ;)given at todomvc
add "a"
toggle "a"
filter active assert no tasks
filter completed
edit "a" to "a edited"
toggle "a edited" assert no tasks
…
Help computer to read it in JavagivenAtTodoMVC();
add("a");
toggle("a");
filterActive(); assertNoTasks();
filterCompleted();
edit("a", "a edited");
toggle("a edited"); assertNoTasks();
//…
public class TodoMVCTest {
@Test public void testTasksLifeCycle(){ givenAtTodoMVC(); add("a"); toggle("a"); filterActive(); assertNoTasks(); filterCompleted(); edit("a", "a edited"); toggle("a edited"); assertNoTasks(); //... }}
public class TodoMVCTest {
@Test public void testTasksLifeCycle(){ givenAtTodoMVC(); add("a"); toggle("a"); filterActive(); assertNoTasks(); filterCompleted(); edit("a", "a edited"); toggle("a edited"); assertNoTasks(); //... }}
?
public static void givenAtTodoMVC(){ open("https://todomvc4tasj.herokuapp.com/"); newTask.shouldBe(enabled);}
givenAtTodoMVC();
public static SelenideElement newTask = $("#new-todo");
newTask
CSS Selector
CSS Selector ?
[id=“new-todo"] = #new-todo
public static SelenideElement newTask = $("#new-todo");
newTask
[id=“new-todo"] <=> #new-todo
public static void add(String taskText) { newTask.setValue(taskText).pressEnter();}
add("a");
public static void toggle(String taskText) { tasks.findBy(exactText(taskText)).$(".toggle").click();}
toggle("a");
public static void toggle(String taskText) { tasks.findBy(exactText(taskText)).$(".toggle").click();}
toggle("a");
public static ElementsCollection tasks = $$("#todo-list>li");
tasks
public static ElementsCollection tasks = $$("#todo-list>li");
tasks
public static void toggle(String taskText) { tasks.findBy(exactText(taskText)).$(".toggle").click();}
toggle("a");
public static void filterActive(){ $(By.linkText("Active")).click();}
filterActive();
By.linkText("Active")
public static void assertNoTasks() { tasks.filterBy(visible).shouldBe(empty);}
assertNoTasks();
tasks.filterBy(visible).shouldBe(empty);
public class TodoMVCTest {
@Test public void testTasksLifeCycle(){ givenAtTodoMVC(); add("a"); toggle("a"); filterActive(); assertNoTasks(); filterCompleted(); edit("a", "a edited"); toggle("a edited"); assertNoTasks(); //... }}
open("https://todomvc4tasj.herokuapp.com/"); newTask.shouldBe(enabled);
newTask = $("#new-todo");tasks = $$("#todo-list>li");
newTask.setValue("a").pressEnter();
tasks.findBy(exactText("a")).$(".toggle").click();
$(By.linkText("Active")).click();
tasks.filterBy(visible).shouldBe(empty);
Easy?
End to Endgo to hole
run
go to tree
hang
eat
go to hole
shleep
Unit/1-feature-per-test
go to tree
shleep invisible
Coverage Style
End to End Unit/1-feature-per-test
Coverage Style
public void testFiltering(){ givenAtTodoMVC(); add("a"); toggle("a"); filterActive(); assertNoTasks(); filterCompleted(); edit("a", "a edited"); toggle("a edited"); assertNoTasks(); //...}
public void testDelete(){ givenAtTodoMVC(); add("a"); delete("a"); assertNoTasks();}
End to End Unit/1-feature-per-test
Advantages
+ more coverage in less time with less efforts during POC
implementation
+ integration coverage
+ in case of bugs, gives more complete report
+ easier to identify reason from the report
=>
+ less time and efforts in support
End to End Unit/1-feature-per-test
When to use?
+ when start, during POC for framework
+ in a rush to cover a lot of existed features
+ for integration coverage
+ for new features
+ after POC is approved, on regular
basis
Wasn’t it easy? :)
Easy tools?
Java: Selenide
Python: Selene is coming…
C#: NSelene is coming…
Ruby: Capybara
? JavaScript: Protractor
? PHP: Codeception
How to start?Choose language
Learn language (books, interactive tutorials, koans, exercism.io, google.com, etc.)
Choose Easy Tools
Find a mentor (friend, dev on your project, it-chats, forums, etc…)
Go :)
Choose language?Have project?
=> choose language of project’s developers
Have no project but want to find work fast?
=> choose one of the most popular language
Have no project but want to code in your style, and it does not matter how long will you seek for the job?
=> choose language that fits you
No ready easy tool for your language?
Lack of knowledge?
=> ask project’s developers to write it for you
Brave?
=> implement it by your own
AfterwordsThere are good practices in context,
but there are no best practices. (c) Cem Kaner, James Bach
Q&A
github.com/yashaka
youtube.com/c/ItlabsNetUa
gitter.im/yashaka/start-selenium
slideshare.net/yashaka
[email protected] @yashaka