SlideShare a Scribd company logo
1 of 45
JAVA EDGE IN
TEST AUTOMATION
28 MAY 2017
2CONFIDENTIAL
Chief QA Automation
More than 12 years in testing
About 10 in test automation
ROMAN IOVLEV
3CONFIDENTIAL
• Java 8
• Lambdas
• Declarative programming
• Examples
• Interfaces
• Data with Lombok
• Java 9 expectations
TOPICS
4CONFIDENTIAL
• “How does Java 8 exert hidden power on Test
Automation?” (https://goo.gl/uT4XfN)
• “Test UI with JDI: easy, simple and good”
(http://goo.gl/Mwta77, https://goo.gl/1kxZS2)
• “Java Tip of the Week #1 – Lombok”
(https://goo.gl/Toxyeh)
INSPIRED WITH
JAVA 8
5
λ
6CONFIDENTIAL
public Function<Integer, String> toStr = i -> i.toString();
public void print(int num, Function<Integer, String> func) {
func.apply(num);
}
print(22, i -> (i / 10)+”decades”);
print(3, toStr);
print(-30, i -> { if (i >0) return i.toString();
return –i; } );
FUNCTION AS VARIABLE
7CONFIDENTIAL
{3, 1, 4, 5, 2, 8, 10, 12, 0, 4, 2, 1, 10, -1}
STREAM
• Even numbers > 3
• Only unique values
• Sorted by Ascending
• Cut 2 lowest and highest values
• Wrap rest of numbers with “( n )”
• And print
“(8)(10)”
8CONFIDENTIAL
//32 strings
public String printResultsJava7(Integer[] strings) {
// Filter
List<Integer> filtered = new ArrayList<>();
for (int s : strings)
if (s > 3 && s % 2 == 0)
filtered.add(s);
//Distinct
List<Integer> distinct = new ArrayList<>();
for (int s : filtered)
if (!distinct.contains(s))
distinct.add(s);
// Sort
Object[] sortedArray = distinct.toArray();
Arrays.sort(sortedArray);
// Trim
List<Integer> trimBounds = new ArrayList<>();
for (int i = 0; i < sortedArray.length; i++)
if (i > 0 || i < sortedArray.length)
trimBounds.add((int)sortedArray[i]);
// Map
List<String> print = new ArrayList<>();
for (int s : trimBounds)
print.add("(" + s + ")");
// Reduce
String result = "";
for (String s : print)
result += s + ";";
return result;
}
JAVA 7
// 6 strings
public String printResultsJava7(Integer[] strings) {
List<Integer> filtered = filter(strings);
List<Integer> distinct = distinct(filtered);
Integer[] sortedArray = sort(distinct);
List<Integer> trimBounds = trim(sortedArray);
List<String> print = print(trimBounds);
return reduce(print);
}
9CONFIDENTIAL
public String Filter(Integer[] strings) {
return stream(strings)
.filter(el -> el > 3 && el % 2 == 0)
.distinct()
.sorted()
.skip(1).limit(1)
.map(el -> "(" + el + ")")
.reduce((str, el) -> el + ";").get();
}
JAVA 8
10CONFIDENTIAL
DECLARATIVE PROGRAMMING
EXAMPLES
11
λ
https://github.com/epam/JDI
12CONFIDENTIAL
public String getMessage(int httpStatus) {
switch(httpStatus) {
case 404:
return “Page not found”;
case 500:
return “Internal Server error”;
default:
return “Unknown status code”;
}
}
SWITCH
13CONFIDENTIAL
public WebElement getVisibleElement(By locator) {
List<WebElement> elements = driver.findElements(locator);
switch(elements) {
case elements.size() == 1 && elements.get(0).isDisplayed():
return elements.get(0),
case elements.size() > 0:
throw new RuntimeException(
format("Find %s elements instead of 1", els.size()));
default:
throw new RuntimeException("Visible elements not found")
); }
SWITCH IMPOSSIBLE
14CONFIDENTIAL
public WebElement getVisibleElement(By locator) {
List<WebElement> elements = driver.findElements(locator);
return Match(elements).of(
Case(els -> els.size() == 1 && els.get(0).isDisplayed(),
els -> els.get(0)),
Case(els -> els.size() > 0,
els -> { throw new RuntimeException(
format("Find %s elements instead of 1", els.size())); }),
Case($(),
() -> { throw new RuntimeException("Visible elements not found") })
); }
JAVASLANG
15CONFIDENTIAL
• Option.of(null) name.toString()
• Try.of(() – 1/0)
• Tuple(“String”, 1, new MyClass())
• Collections,
• Validate
• Functions etc…
JAVASLANG
http://www.baeldung.com/javaslang
16CONFIDENTIAL
PRECONDITIONS
public enum Preconditions implements IPreconditions {
LOGGED_IN(() -> loggedIn(),
() -> { loginPage.open();
loginForm.login(); }),
CAREERS_PAGE("/careers");
….
} 1.Is in expected state?
2.How to get this state?
17CONFIDENTIAL
PRECONDITIONS
@Test
public void simpleTest() {
isInState(LOGGED_IN)
…
};
States.isLoggedIn();
18CONFIDENTIAL
PRECONDITIONS
public class States() {
public static void isLoggedIn() {
logger.info("Move to condition: " + condition);
if (loggedIn()) return;
logIn();
if (!loggedIn())
throw new Exception(“Can’t log In”);
else
logger.info(“User logedIn succesfullly");
};
}
public class States() {
public static void isLoggedIn() {
logger.info("Move to condition: " + condition);
if (loggedIn()) return;
logIn();
if (!loggedIn())
throw new Exception(“Can’t log In”);
else
logger.info(“User logedIn succesfullly");
};
public static void isLoggedIn() {
logger.info("Move to condition: " + condition);
if (loggedIn()) return;
logIn();
if (!loggedIn())
throw new Exception(“Can’t log In”);
else
logger.info(“User logedIn succesfullly");
};
public static void isLoggedIn() {
logger.info("Move to condition: " + condition);
if (loggedIn()) return;
logIn();
if (!loggedIn())
throw new Exception(“Can’t log In”);
else
logger.info(“User logedIn succesfullly");
};
}
public static void isLoggedIn() {
logger.info("Move to condition: " + condition);
if (loggedIn()) return;
logIn();
if (!loggedIn())
throw new Exception(“Can’t log In”);
else
logger.info(“User logedIn succesfullly");
};
public static void isLoggedIn() {
logger.info("Move to condition: " + condition);
if (loggedIn()) return;
logIn();
if (!loggedIn())
throw new Exception(“Can’t log In”);
else
logger.info(“User logedIn succesfullly");
};
public static void isLoggedIn() {
logger.info("Move to condition: " + condition);
if (loggedIn()) return;
logIn();
if (!loggedIn())
throw new Exception(“Can’t log In”);
else
logger.info(“User logedIn succesfullly");
};
}
19CONFIDENTIAL
ENTITY TABLES
@Data
public class Entity {
public String Номер;
public String Тип;
public String Пользователь;
public String Описание;
}
public class Row {
public Text Номер;
public Dropdown Тип;
public Link Пользователь;
public Description Описание;
}
20CONFIDENTIAL
Row user = UsersTable.firstRow(row ->
textOf(row.description).contains(“tasks”) &&
textOf(row.type).equals(“Admin”));
user.description.choosen.select();
ENTITY TABLES
CheckboxColumn name
21CONFIDENTIAL
ENTITY TABLES
One method instead of
dozens methods for each
combination
22CONFIDENTIAL
FUNCTIONS AND PREDICATES
find(max(Product::getPrice);
find(min(Product::getPrice);
find(max(Product::getName);
find(max(User::getPrice);
getElement(WebElement::isDisplayed, unique);
getDriver(maxSize(chrome));
23CONFIDENTIAL
CUSTOM SCENARIOS
@BeforeSuite (alwaysRun = true)
public static void setUp() {
ActionScenrios.actionScenario = (element, actionName, jAction, level) -> {
logger.info(format("Do '%s' action", actionName));
jAction.invoke();
};
ActionScenrios.resultScenario = (element, actionName, jAction, logResult,
level) -> {
logger.debug(format("Do '%s' action", actionName));
Object result = jAction.get();
logger.info(format("Get '%s' action result: %s", actionName, result));
return result;
};
} Like AOP
24CONFIDENTIAL
Assert.areEquals(() -> getNext(), "IPhone 6");
Assert.contains(() -> getNext(), "IPhone 5");
WAIT ASSERT
Значение станет равно X в течении таймаута
25CONFIDENTIAL
• Incredible flexibility
• Greatly reduce code
amount
PROS N’ CONS
• Learn lambda staff
• Change your and your teammates
mind
• Sometimes more complex debug
JAVA 8
26
INTERFACES
27CONFIDENTIAL
public interface IForm<T> {
void submit(String text, String btnName);
default void login(String text) { submit(text, "login"); }
default void loginAs(String text) { login(text); }
default void add(String text) { submit(text, "add"); }
default void publish(String text) { submit(text, "publish"); }
static T ToEntity(IForm<T>) { … }
static final int PAGE_NOT_FOUND = 404;
…
INTERFACES
28CONFIDENTIAL
MULTI INHERITANCE
public interface ITextField {
void input();
void newInput();
String getValue();
}
public interface ICombobox extends IDropDown, ITextField {
}
public interface Dropdown {
void select();
void open();
}
void input();
void newInput();
String getValue();
void select();
void open();
JAVA 8
29
DATA
30CONFIDENTIAL
3
DATA CLASS
public class Product {
public String name;
public int id;
public Types type;
}
31CONFIDENTIAL
CONSTRUCTORS AND TOSTRING
public Product() {}
public Product(String name, int id, Types type) {
this.name = name;
this.id = id;
this.type = type;
}
@Override
public String toString() {
return String.format("Name: %s, Id: %s, Type: %s", name, id, type);
}
+10
32CONFIDENTIAL
EQUALS AND HASHCODE
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (!Product.class.isAssignableFrom(obj.getClass())) {
return false;
}
final Product other = (Product) obj;
if (name == null)
return other.name == null;
return this.name.equals(other.name) &&
this.id == other.id &&
this.type == other.type;
}
@Override
public int hashCode() {
int hash = 3;
hash = 53 * hash + (name != null ? name.hashCode() : 0);
hash = 53 * hash + id;
hash = 53 * hash + type.hashCode();
return hash;
}
+23
33CONFIDENTIAL
@Data
public class Product {
public String name;
public int id;
public Types type;
}
LOMBOK
36 строк кода
1 аннотация
или
34CONFIDENTIAL
Add different Constructors
Add Getters and Setters
Add Builder pattern
Add good ToString
Add good Equals
LOMBOK
WARNING
This can really confuse
external users
ENTITY DRIVEN
TESTING
35
36CONFIDENTIAL
EDT: DATA DRIVEN TESTING
 Provide List<User> for test
37CONFIDENTIAL
EDT: PRECONDITIONS
 Provide List<User> for test
0. Have DefaultUser in DB
38CONFIDENTIAL
EDT: FILL AND SUBMIT
 Provide List<User> for test
0. Have DefaultUser in DB
1. Login with DefaultUser
39CONFIDENTIAL
EDT: FILL AND SEND
 Provide List<User> for test
0. Have DefaultUser in DB
1. Login with DefaultUser
2. Submit Contact Us Form for DefaultUser
40CONFIDENTIAL
EDT: EXTRACT
 Provide List<User> for test
0. Have DefaultUser in DB
1. Login with DefaultUser
2. Submit Contact Us Form for DefaultUser
3. Get Act. Opening from Vacancy table
41CONFIDENTIAL
EDT: VALIDATE
 Provide List<User> for test
0. Have DefaultUser in DB
1. Login with DefaultUser
2. Submit Contact Us Form for DefaultUser
3. Get Act. Opening from Vacancy table
4. Assert Act. Opening equals to Exp. Opening
ExpectedActual
42CONFIDENTIAL
EDT & JDI
DB.Users.shouldPresent(user);
LoginForm.login(user);
ConactUsForm.send(user);
Vacancy vacancy= OpeningsTable.entity(inRow(2));
Assert.areEquals(vacancy, expectedVacancy);
43CONFIDENTIAL
Learn language features
Learn modern tools and frameworks
Use popular approaches
Do your work better (write tests faster, more
stable, with better quality etc.)
Have fun with your work!
CONCLUSIONS
44CONFIDENTIAL
• Modularity
• New HTTP Client (Http2.0 & WebSocket)
• Improved Process API
• Language try-new, anonymous Diamond, private in
interfaces, immutable set, list-optional to stream
• Improved logging…
JAVA 9
http://www.baeldung.com/new-java-9
27.07.2017
45CONFIDENTIAL
QUESTIONS?
roman.Iovlev
roman_iovlev@epam.com

More Related Content

What's hot

Java 7 Launch Event at LyonJUG, Lyon France. Fork / Join framework and Projec...
Java 7 Launch Event at LyonJUG, Lyon France. Fork / Join framework and Projec...Java 7 Launch Event at LyonJUG, Lyon France. Fork / Join framework and Projec...
Java 7 Launch Event at LyonJUG, Lyon France. Fork / Join framework and Projec...julien.ponge
 
Software Testing - Invited Lecture at UNSW Sydney
Software Testing - Invited Lecture at UNSW SydneySoftware Testing - Invited Lecture at UNSW Sydney
Software Testing - Invited Lecture at UNSW Sydneyjulien.ponge
 
ES3-2020-P3 TDD Calculator
ES3-2020-P3 TDD CalculatorES3-2020-P3 TDD Calculator
ES3-2020-P3 TDD CalculatorDavid Rodenas
 
Introduction to web programming for java and c# programmers by @drpicox
Introduction to web programming for java and c# programmers by @drpicoxIntroduction to web programming for java and c# programmers by @drpicox
Introduction to web programming for java and c# programmers by @drpicoxDavid Rodenas
 
GeeCON 2017 - TestContainers. Integration testing without the hassle
GeeCON 2017 - TestContainers. Integration testing without the hassleGeeCON 2017 - TestContainers. Integration testing without the hassle
GeeCON 2017 - TestContainers. Integration testing without the hassleAnton Arhipov
 
Java Bytecode for Discriminating Developers - JavaZone 2011
Java Bytecode for Discriminating Developers - JavaZone 2011Java Bytecode for Discriminating Developers - JavaZone 2011
Java Bytecode for Discriminating Developers - JavaZone 2011Anton Arhipov
 
The Ring programming language version 1.6 book - Part 184 of 189
The Ring programming language version 1.6 book - Part 184 of 189The Ring programming language version 1.6 book - Part 184 of 189
The Ring programming language version 1.6 book - Part 184 of 189Mahmoud Samir Fayed
 
Дмитрий Контрерас «Back to the future: the evolution of the Java Type System»
Дмитрий Контрерас «Back to the future: the evolution of the Java Type System»Дмитрий Контрерас «Back to the future: the evolution of the Java Type System»
Дмитрий Контрерас «Back to the future: the evolution of the Java Type System»Anna Shymchenko
 
ReactJS for Programmers
ReactJS for ProgrammersReactJS for Programmers
ReactJS for ProgrammersDavid Rodenas
 
soft-shake.ch - Java SE 7: The Fork/Join Framework and Project Coin
soft-shake.ch - Java SE 7: The Fork/Join Framework and Project Coinsoft-shake.ch - Java SE 7: The Fork/Join Framework and Project Coin
soft-shake.ch - Java SE 7: The Fork/Join Framework and Project Coinsoft-shake.ch
 
Kotlin : Advanced Tricks - Ubiratan Soares
Kotlin : Advanced Tricks - Ubiratan SoaresKotlin : Advanced Tricks - Ubiratan Soares
Kotlin : Advanced Tricks - Ubiratan SoaresiMasters
 
Conf soat tests_unitaires_Mockito_jUnit_170113
Conf soat tests_unitaires_Mockito_jUnit_170113Conf soat tests_unitaires_Mockito_jUnit_170113
Conf soat tests_unitaires_Mockito_jUnit_170113SOAT
 

What's hot (20)

Sam wd programs
Sam wd programsSam wd programs
Sam wd programs
 
Java 7 Launch Event at LyonJUG, Lyon France. Fork / Join framework and Projec...
Java 7 Launch Event at LyonJUG, Lyon France. Fork / Join framework and Projec...Java 7 Launch Event at LyonJUG, Lyon France. Fork / Join framework and Projec...
Java 7 Launch Event at LyonJUG, Lyon France. Fork / Join framework and Projec...
 
Java 7 LavaJUG
Java 7 LavaJUGJava 7 LavaJUG
Java 7 LavaJUG
 
JavaZone 2014 - goto java;
JavaZone 2014 - goto java;JavaZone 2014 - goto java;
JavaZone 2014 - goto java;
 
JS and patterns
JS and patternsJS and patterns
JS and patterns
 
Easy Button
Easy ButtonEasy Button
Easy Button
 
Software Testing - Invited Lecture at UNSW Sydney
Software Testing - Invited Lecture at UNSW SydneySoftware Testing - Invited Lecture at UNSW Sydney
Software Testing - Invited Lecture at UNSW Sydney
 
Migrating to JUnit 5
Migrating to JUnit 5Migrating to JUnit 5
Migrating to JUnit 5
 
ES3-2020-P3 TDD Calculator
ES3-2020-P3 TDD CalculatorES3-2020-P3 TDD Calculator
ES3-2020-P3 TDD Calculator
 
Introduction to web programming for java and c# programmers by @drpicox
Introduction to web programming for java and c# programmers by @drpicoxIntroduction to web programming for java and c# programmers by @drpicox
Introduction to web programming for java and c# programmers by @drpicox
 
GeeCON 2017 - TestContainers. Integration testing without the hassle
GeeCON 2017 - TestContainers. Integration testing without the hassleGeeCON 2017 - TestContainers. Integration testing without the hassle
GeeCON 2017 - TestContainers. Integration testing without the hassle
 
Java Bytecode for Discriminating Developers - JavaZone 2011
Java Bytecode for Discriminating Developers - JavaZone 2011Java Bytecode for Discriminating Developers - JavaZone 2011
Java Bytecode for Discriminating Developers - JavaZone 2011
 
Unit testing concurrent code
Unit testing concurrent codeUnit testing concurrent code
Unit testing concurrent code
 
The Ring programming language version 1.6 book - Part 184 of 189
The Ring programming language version 1.6 book - Part 184 of 189The Ring programming language version 1.6 book - Part 184 of 189
The Ring programming language version 1.6 book - Part 184 of 189
 
Дмитрий Контрерас «Back to the future: the evolution of the Java Type System»
Дмитрий Контрерас «Back to the future: the evolution of the Java Type System»Дмитрий Контрерас «Back to the future: the evolution of the Java Type System»
Дмитрий Контрерас «Back to the future: the evolution of the Java Type System»
 
ReactJS for Programmers
ReactJS for ProgrammersReactJS for Programmers
ReactJS for Programmers
 
Server1
Server1Server1
Server1
 
soft-shake.ch - Java SE 7: The Fork/Join Framework and Project Coin
soft-shake.ch - Java SE 7: The Fork/Join Framework and Project Coinsoft-shake.ch - Java SE 7: The Fork/Join Framework and Project Coin
soft-shake.ch - Java SE 7: The Fork/Join Framework and Project Coin
 
Kotlin : Advanced Tricks - Ubiratan Soares
Kotlin : Advanced Tricks - Ubiratan SoaresKotlin : Advanced Tricks - Ubiratan Soares
Kotlin : Advanced Tricks - Ubiratan Soares
 
Conf soat tests_unitaires_Mockito_jUnit_170113
Conf soat tests_unitaires_Mockito_jUnit_170113Conf soat tests_unitaires_Mockito_jUnit_170113
Conf soat tests_unitaires_Mockito_jUnit_170113
 

Similar to #ITsubbotnik Spring 2017: Roman Iovlev "Java edge in test automation"

Teste de Integração com DbUnit e jIntegrity
Teste de Integração com DbUnit e jIntegrityTeste de Integração com DbUnit e jIntegrity
Teste de Integração com DbUnit e jIntegrityWashington Botelho
 
code for quiz in my sql
code for quiz  in my sql code for quiz  in my sql
code for quiz in my sql JOYITAKUNDU1
 
Kotlin Developer Starter in Android projects
Kotlin Developer Starter in Android projectsKotlin Developer Starter in Android projects
Kotlin Developer Starter in Android projectsBartosz Kosarzycki
 
Kotlin Developer Starter in Android - STX Next Lightning Talks - Feb 12, 2016
Kotlin Developer Starter in Android - STX Next Lightning Talks - Feb 12, 2016Kotlin Developer Starter in Android - STX Next Lightning Talks - Feb 12, 2016
Kotlin Developer Starter in Android - STX Next Lightning Talks - Feb 12, 2016STX Next
 
Testing in android
Testing in androidTesting in android
Testing in androidjtrindade
 
A evolução da persistência de dados (com sqlite) no android
A evolução da persistência de dados (com sqlite) no androidA evolução da persistência de dados (com sqlite) no android
A evolução da persistência de dados (com sqlite) no androidRodrigo de Souza Castro
 
33rd Degree 2013, Bad Tests, Good Tests
33rd Degree 2013, Bad Tests, Good Tests33rd Degree 2013, Bad Tests, Good Tests
33rd Degree 2013, Bad Tests, Good TestsTomek Kaczanowski
 
Jug trojmiasto 2014.04.24 tricky stuff in java grammar and javac
Jug trojmiasto 2014.04.24  tricky stuff in java grammar and javacJug trojmiasto 2014.04.24  tricky stuff in java grammar and javac
Jug trojmiasto 2014.04.24 tricky stuff in java grammar and javacAnna Brzezińska
 
Android testing
Android testingAndroid testing
Android testingSean Tsai
 
JVM Mechanics: When Does the JVM JIT & Deoptimize?
JVM Mechanics: When Does the JVM JIT & Deoptimize?JVM Mechanics: When Does the JVM JIT & Deoptimize?
JVM Mechanics: When Does the JVM JIT & Deoptimize?Doug Hawkins
 
Mobile Programming - Network Universitas Budi Luhur
Mobile Programming - Network Universitas Budi LuhurMobile Programming - Network Universitas Budi Luhur
Mobile Programming - Network Universitas Budi LuhurRiza Fahmi
 
How to Start Test-Driven Development in Legacy Code
How to Start Test-Driven Development in Legacy CodeHow to Start Test-Driven Development in Legacy Code
How to Start Test-Driven Development in Legacy CodeDaniel Wellman
 
RxJava и Android. Плюсы, минусы, подводные камни
RxJava и Android. Плюсы, минусы, подводные камниRxJava и Android. Плюсы, минусы, подводные камни
RxJava и Android. Плюсы, минусы, подводные камниStfalcon Meetups
 
Reactive programming on Android
Reactive programming on AndroidReactive programming on Android
Reactive programming on AndroidTomáš Kypta
 
Imagine a world without mocks
Imagine a world without mocksImagine a world without mocks
Imagine a world without mockskenbot
 

Similar to #ITsubbotnik Spring 2017: Roman Iovlev "Java edge in test automation" (20)

Teste de Integração com DbUnit e jIntegrity
Teste de Integração com DbUnit e jIntegrityTeste de Integração com DbUnit e jIntegrity
Teste de Integração com DbUnit e jIntegrity
 
SOLID Principles
SOLID PrinciplesSOLID Principles
SOLID Principles
 
code for quiz in my sql
code for quiz  in my sql code for quiz  in my sql
code for quiz in my sql
 
Kotlin Developer Starter in Android projects
Kotlin Developer Starter in Android projectsKotlin Developer Starter in Android projects
Kotlin Developer Starter in Android projects
 
Kotlin Developer Starter in Android - STX Next Lightning Talks - Feb 12, 2016
Kotlin Developer Starter in Android - STX Next Lightning Talks - Feb 12, 2016Kotlin Developer Starter in Android - STX Next Lightning Talks - Feb 12, 2016
Kotlin Developer Starter in Android - STX Next Lightning Talks - Feb 12, 2016
 
Testing in android
Testing in androidTesting in android
Testing in android
 
Griffon @ Svwjug
Griffon @ SvwjugGriffon @ Svwjug
Griffon @ Svwjug
 
A evolução da persistência de dados (com sqlite) no android
A evolução da persistência de dados (com sqlite) no androidA evolução da persistência de dados (com sqlite) no android
A evolução da persistência de dados (com sqlite) no android
 
33rd Degree 2013, Bad Tests, Good Tests
33rd Degree 2013, Bad Tests, Good Tests33rd Degree 2013, Bad Tests, Good Tests
33rd Degree 2013, Bad Tests, Good Tests
 
Jug trojmiasto 2014.04.24 tricky stuff in java grammar and javac
Jug trojmiasto 2014.04.24  tricky stuff in java grammar and javacJug trojmiasto 2014.04.24  tricky stuff in java grammar and javac
Jug trojmiasto 2014.04.24 tricky stuff in java grammar and javac
 
Kotlin
KotlinKotlin
Kotlin
 
Android testing
Android testingAndroid testing
Android testing
 
All things that are not code
All things that are not codeAll things that are not code
All things that are not code
 
JVM Mechanics: When Does the JVM JIT & Deoptimize?
JVM Mechanics: When Does the JVM JIT & Deoptimize?JVM Mechanics: When Does the JVM JIT & Deoptimize?
JVM Mechanics: When Does the JVM JIT & Deoptimize?
 
Mobile Programming - Network Universitas Budi Luhur
Mobile Programming - Network Universitas Budi LuhurMobile Programming - Network Universitas Budi Luhur
Mobile Programming - Network Universitas Budi Luhur
 
How to Start Test-Driven Development in Legacy Code
How to Start Test-Driven Development in Legacy CodeHow to Start Test-Driven Development in Legacy Code
How to Start Test-Driven Development in Legacy Code
 
RxJava и Android. Плюсы, минусы, подводные камни
RxJava и Android. Плюсы, минусы, подводные камниRxJava и Android. Плюсы, минусы, подводные камни
RxJava и Android. Плюсы, минусы, подводные камни
 
Reactive programming on Android
Reactive programming on AndroidReactive programming on Android
Reactive programming on Android
 
Imagine a world without mocks
Imagine a world without mocksImagine a world without mocks
Imagine a world without mocks
 
Clean coding-practices
Clean coding-practicesClean coding-practices
Clean coding-practices
 

More from epamspb

Mobile Open Day: React Native: Crossplatform fast dive
Mobile Open Day: React Native: Crossplatform fast diveMobile Open Day: React Native: Crossplatform fast dive
Mobile Open Day: React Native: Crossplatform fast diveepamspb
 
Mobile Open Day: Things I wish I'd known about Core Data before getting married
Mobile Open Day: Things I wish I'd known about Core Data before getting marriedMobile Open Day: Things I wish I'd known about Core Data before getting married
Mobile Open Day: Things I wish I'd known about Core Data before getting marriedepamspb
 
#ITsubbotnik Spring 2017: Sergey Chibirev/Andrei Ortyashov "Умный дом своими ...
#ITsubbotnik Spring 2017: Sergey Chibirev/Andrei Ortyashov "Умный дом своими ...#ITsubbotnik Spring 2017: Sergey Chibirev/Andrei Ortyashov "Умный дом своими ...
#ITsubbotnik Spring 2017: Sergey Chibirev/Andrei Ortyashov "Умный дом своими ...epamspb
 
#ITsubbotnik Spring 2017: Stepan Rakitin "Создаем отказоустойчивые распределе...
#ITsubbotnik Spring 2017: Stepan Rakitin "Создаем отказоустойчивые распределе...#ITsubbotnik Spring 2017: Stepan Rakitin "Создаем отказоустойчивые распределе...
#ITsubbotnik Spring 2017: Stepan Rakitin "Создаем отказоустойчивые распределе...epamspb
 
#ITsubbotnik Spring 2017: Rustam Kadyrov "Как приструнить зоопарк из микросер...
#ITsubbotnik Spring 2017: Rustam Kadyrov "Как приструнить зоопарк из микросер...#ITsubbotnik Spring 2017: Rustam Kadyrov "Как приструнить зоопарк из микросер...
#ITsubbotnik Spring 2017: Rustam Kadyrov "Как приструнить зоопарк из микросер...epamspb
 
ITsubbotnik Spring 2017: Dmitriy Yatsyuk "Готовое комплексное инфраструктурно...
ITsubbotnik Spring 2017: Dmitriy Yatsyuk "Готовое комплексное инфраструктурно...ITsubbotnik Spring 2017: Dmitriy Yatsyuk "Готовое комплексное инфраструктурно...
ITsubbotnik Spring 2017: Dmitriy Yatsyuk "Готовое комплексное инфраструктурно...epamspb
 
#ITsubbotnik Spring 2017: Sergey Chernolyas "JPA for NoSQL"
#ITsubbotnik Spring 2017: Sergey Chernolyas "JPA for NoSQL"#ITsubbotnik Spring 2017: Sergey Chernolyas "JPA for NoSQL"
#ITsubbotnik Spring 2017: Sergey Chernolyas "JPA for NoSQL"epamspb
 
#ITsubbotnik Spring 2017: Dmitrii Nikitko "Deep learning for understanding of...
#ITsubbotnik Spring 2017: Dmitrii Nikitko "Deep learning for understanding of...#ITsubbotnik Spring 2017: Dmitrii Nikitko "Deep learning for understanding of...
#ITsubbotnik Spring 2017: Dmitrii Nikitko "Deep learning for understanding of...epamspb
 
#ITsubbotnik Spring 2017: Roman Dimitrenko "Building Paas with the HashiStack"
#ITsubbotnik Spring 2017: Roman Dimitrenko "Building Paas with the HashiStack"#ITsubbotnik Spring 2017: Roman Dimitrenko "Building Paas with the HashiStack"
#ITsubbotnik Spring 2017: Roman Dimitrenko "Building Paas with the HashiStack"epamspb
 
#ITsubbotnik Spring 2017: Mikhail Khludnev "Search like %SQL%"
#ITsubbotnik Spring 2017: Mikhail Khludnev "Search like %SQL%"#ITsubbotnik Spring 2017: Mikhail Khludnev "Search like %SQL%"
#ITsubbotnik Spring 2017: Mikhail Khludnev "Search like %SQL%"epamspb
 
#ITsubbotnik Spring 2017: Andriy Filatov "Ансамбль солёных поваров: сравнивае...
#ITsubbotnik Spring 2017: Andriy Filatov "Ансамбль солёных поваров: сравнивае...#ITsubbotnik Spring 2017: Andriy Filatov "Ансамбль солёных поваров: сравнивае...
#ITsubbotnik Spring 2017: Andriy Filatov "Ансамбль солёных поваров: сравнивае...epamspb
 
#ITsubbotnik Spring 2017: Anton Shapin, Denis Klykov "Visualization, storage ...
#ITsubbotnik Spring 2017: Anton Shapin, Denis Klykov "Visualization, storage ...#ITsubbotnik Spring 2017: Anton Shapin, Denis Klykov "Visualization, storage ...
#ITsubbotnik Spring 2017: Anton Shapin, Denis Klykov "Visualization, storage ...epamspb
 
#ITsubbotnik Spring 2017: Sergey Mishanin "Report Portal. Руководство для аде...
#ITsubbotnik Spring 2017: Sergey Mishanin "Report Portal. Руководство для аде...#ITsubbotnik Spring 2017: Sergey Mishanin "Report Portal. Руководство для аде...
#ITsubbotnik Spring 2017: Sergey Mishanin "Report Portal. Руководство для аде...epamspb
 

More from epamspb (13)

Mobile Open Day: React Native: Crossplatform fast dive
Mobile Open Day: React Native: Crossplatform fast diveMobile Open Day: React Native: Crossplatform fast dive
Mobile Open Day: React Native: Crossplatform fast dive
 
Mobile Open Day: Things I wish I'd known about Core Data before getting married
Mobile Open Day: Things I wish I'd known about Core Data before getting marriedMobile Open Day: Things I wish I'd known about Core Data before getting married
Mobile Open Day: Things I wish I'd known about Core Data before getting married
 
#ITsubbotnik Spring 2017: Sergey Chibirev/Andrei Ortyashov "Умный дом своими ...
#ITsubbotnik Spring 2017: Sergey Chibirev/Andrei Ortyashov "Умный дом своими ...#ITsubbotnik Spring 2017: Sergey Chibirev/Andrei Ortyashov "Умный дом своими ...
#ITsubbotnik Spring 2017: Sergey Chibirev/Andrei Ortyashov "Умный дом своими ...
 
#ITsubbotnik Spring 2017: Stepan Rakitin "Создаем отказоустойчивые распределе...
#ITsubbotnik Spring 2017: Stepan Rakitin "Создаем отказоустойчивые распределе...#ITsubbotnik Spring 2017: Stepan Rakitin "Создаем отказоустойчивые распределе...
#ITsubbotnik Spring 2017: Stepan Rakitin "Создаем отказоустойчивые распределе...
 
#ITsubbotnik Spring 2017: Rustam Kadyrov "Как приструнить зоопарк из микросер...
#ITsubbotnik Spring 2017: Rustam Kadyrov "Как приструнить зоопарк из микросер...#ITsubbotnik Spring 2017: Rustam Kadyrov "Как приструнить зоопарк из микросер...
#ITsubbotnik Spring 2017: Rustam Kadyrov "Как приструнить зоопарк из микросер...
 
ITsubbotnik Spring 2017: Dmitriy Yatsyuk "Готовое комплексное инфраструктурно...
ITsubbotnik Spring 2017: Dmitriy Yatsyuk "Готовое комплексное инфраструктурно...ITsubbotnik Spring 2017: Dmitriy Yatsyuk "Готовое комплексное инфраструктурно...
ITsubbotnik Spring 2017: Dmitriy Yatsyuk "Готовое комплексное инфраструктурно...
 
#ITsubbotnik Spring 2017: Sergey Chernolyas "JPA for NoSQL"
#ITsubbotnik Spring 2017: Sergey Chernolyas "JPA for NoSQL"#ITsubbotnik Spring 2017: Sergey Chernolyas "JPA for NoSQL"
#ITsubbotnik Spring 2017: Sergey Chernolyas "JPA for NoSQL"
 
#ITsubbotnik Spring 2017: Dmitrii Nikitko "Deep learning for understanding of...
#ITsubbotnik Spring 2017: Dmitrii Nikitko "Deep learning for understanding of...#ITsubbotnik Spring 2017: Dmitrii Nikitko "Deep learning for understanding of...
#ITsubbotnik Spring 2017: Dmitrii Nikitko "Deep learning for understanding of...
 
#ITsubbotnik Spring 2017: Roman Dimitrenko "Building Paas with the HashiStack"
#ITsubbotnik Spring 2017: Roman Dimitrenko "Building Paas with the HashiStack"#ITsubbotnik Spring 2017: Roman Dimitrenko "Building Paas with the HashiStack"
#ITsubbotnik Spring 2017: Roman Dimitrenko "Building Paas with the HashiStack"
 
#ITsubbotnik Spring 2017: Mikhail Khludnev "Search like %SQL%"
#ITsubbotnik Spring 2017: Mikhail Khludnev "Search like %SQL%"#ITsubbotnik Spring 2017: Mikhail Khludnev "Search like %SQL%"
#ITsubbotnik Spring 2017: Mikhail Khludnev "Search like %SQL%"
 
#ITsubbotnik Spring 2017: Andriy Filatov "Ансамбль солёных поваров: сравнивае...
#ITsubbotnik Spring 2017: Andriy Filatov "Ансамбль солёных поваров: сравнивае...#ITsubbotnik Spring 2017: Andriy Filatov "Ансамбль солёных поваров: сравнивае...
#ITsubbotnik Spring 2017: Andriy Filatov "Ансамбль солёных поваров: сравнивае...
 
#ITsubbotnik Spring 2017: Anton Shapin, Denis Klykov "Visualization, storage ...
#ITsubbotnik Spring 2017: Anton Shapin, Denis Klykov "Visualization, storage ...#ITsubbotnik Spring 2017: Anton Shapin, Denis Klykov "Visualization, storage ...
#ITsubbotnik Spring 2017: Anton Shapin, Denis Klykov "Visualization, storage ...
 
#ITsubbotnik Spring 2017: Sergey Mishanin "Report Portal. Руководство для аде...
#ITsubbotnik Spring 2017: Sergey Mishanin "Report Portal. Руководство для аде...#ITsubbotnik Spring 2017: Sergey Mishanin "Report Portal. Руководство для аде...
#ITsubbotnik Spring 2017: Sergey Mishanin "Report Portal. Руководство для аде...
 

Recently uploaded

Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - InfographicHr365.us smith
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Hr365.us smith
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesPhilip Schwarz
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfAlina Yurenko
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作qr0udbr0
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfPower Karaoke
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...OnePlan Solutions
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....kzayra69
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsAhmed Mohamed
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesŁukasz Chruściel
 

Recently uploaded (20)

Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - Infographic
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a series
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdf
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML Diagrams
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New Features
 

#ITsubbotnik Spring 2017: Roman Iovlev "Java edge in test automation"

  • 1. JAVA EDGE IN TEST AUTOMATION 28 MAY 2017
  • 2. 2CONFIDENTIAL Chief QA Automation More than 12 years in testing About 10 in test automation ROMAN IOVLEV
  • 3. 3CONFIDENTIAL • Java 8 • Lambdas • Declarative programming • Examples • Interfaces • Data with Lombok • Java 9 expectations TOPICS
  • 4. 4CONFIDENTIAL • “How does Java 8 exert hidden power on Test Automation?” (https://goo.gl/uT4XfN) • “Test UI with JDI: easy, simple and good” (http://goo.gl/Mwta77, https://goo.gl/1kxZS2) • “Java Tip of the Week #1 – Lombok” (https://goo.gl/Toxyeh) INSPIRED WITH
  • 6. 6CONFIDENTIAL public Function<Integer, String> toStr = i -> i.toString(); public void print(int num, Function<Integer, String> func) { func.apply(num); } print(22, i -> (i / 10)+”decades”); print(3, toStr); print(-30, i -> { if (i >0) return i.toString(); return –i; } ); FUNCTION AS VARIABLE
  • 7. 7CONFIDENTIAL {3, 1, 4, 5, 2, 8, 10, 12, 0, 4, 2, 1, 10, -1} STREAM • Even numbers > 3 • Only unique values • Sorted by Ascending • Cut 2 lowest and highest values • Wrap rest of numbers with “( n )” • And print “(8)(10)”
  • 8. 8CONFIDENTIAL //32 strings public String printResultsJava7(Integer[] strings) { // Filter List<Integer> filtered = new ArrayList<>(); for (int s : strings) if (s > 3 && s % 2 == 0) filtered.add(s); //Distinct List<Integer> distinct = new ArrayList<>(); for (int s : filtered) if (!distinct.contains(s)) distinct.add(s); // Sort Object[] sortedArray = distinct.toArray(); Arrays.sort(sortedArray); // Trim List<Integer> trimBounds = new ArrayList<>(); for (int i = 0; i < sortedArray.length; i++) if (i > 0 || i < sortedArray.length) trimBounds.add((int)sortedArray[i]); // Map List<String> print = new ArrayList<>(); for (int s : trimBounds) print.add("(" + s + ")"); // Reduce String result = ""; for (String s : print) result += s + ";"; return result; } JAVA 7 // 6 strings public String printResultsJava7(Integer[] strings) { List<Integer> filtered = filter(strings); List<Integer> distinct = distinct(filtered); Integer[] sortedArray = sort(distinct); List<Integer> trimBounds = trim(sortedArray); List<String> print = print(trimBounds); return reduce(print); }
  • 9. 9CONFIDENTIAL public String Filter(Integer[] strings) { return stream(strings) .filter(el -> el > 3 && el % 2 == 0) .distinct() .sorted() .skip(1).limit(1) .map(el -> "(" + el + ")") .reduce((str, el) -> el + ";").get(); } JAVA 8
  • 12. 12CONFIDENTIAL public String getMessage(int httpStatus) { switch(httpStatus) { case 404: return “Page not found”; case 500: return “Internal Server error”; default: return “Unknown status code”; } } SWITCH
  • 13. 13CONFIDENTIAL public WebElement getVisibleElement(By locator) { List<WebElement> elements = driver.findElements(locator); switch(elements) { case elements.size() == 1 && elements.get(0).isDisplayed(): return elements.get(0), case elements.size() > 0: throw new RuntimeException( format("Find %s elements instead of 1", els.size())); default: throw new RuntimeException("Visible elements not found") ); } SWITCH IMPOSSIBLE
  • 14. 14CONFIDENTIAL public WebElement getVisibleElement(By locator) { List<WebElement> elements = driver.findElements(locator); return Match(elements).of( Case(els -> els.size() == 1 && els.get(0).isDisplayed(), els -> els.get(0)), Case(els -> els.size() > 0, els -> { throw new RuntimeException( format("Find %s elements instead of 1", els.size())); }), Case($(), () -> { throw new RuntimeException("Visible elements not found") }) ); } JAVASLANG
  • 15. 15CONFIDENTIAL • Option.of(null) name.toString() • Try.of(() – 1/0) • Tuple(“String”, 1, new MyClass()) • Collections, • Validate • Functions etc… JAVASLANG http://www.baeldung.com/javaslang
  • 16. 16CONFIDENTIAL PRECONDITIONS public enum Preconditions implements IPreconditions { LOGGED_IN(() -> loggedIn(), () -> { loginPage.open(); loginForm.login(); }), CAREERS_PAGE("/careers"); …. } 1.Is in expected state? 2.How to get this state?
  • 17. 17CONFIDENTIAL PRECONDITIONS @Test public void simpleTest() { isInState(LOGGED_IN) … }; States.isLoggedIn();
  • 18. 18CONFIDENTIAL PRECONDITIONS public class States() { public static void isLoggedIn() { logger.info("Move to condition: " + condition); if (loggedIn()) return; logIn(); if (!loggedIn()) throw new Exception(“Can’t log In”); else logger.info(“User logedIn succesfullly"); }; } public class States() { public static void isLoggedIn() { logger.info("Move to condition: " + condition); if (loggedIn()) return; logIn(); if (!loggedIn()) throw new Exception(“Can’t log In”); else logger.info(“User logedIn succesfullly"); }; public static void isLoggedIn() { logger.info("Move to condition: " + condition); if (loggedIn()) return; logIn(); if (!loggedIn()) throw new Exception(“Can’t log In”); else logger.info(“User logedIn succesfullly"); }; public static void isLoggedIn() { logger.info("Move to condition: " + condition); if (loggedIn()) return; logIn(); if (!loggedIn()) throw new Exception(“Can’t log In”); else logger.info(“User logedIn succesfullly"); }; } public static void isLoggedIn() { logger.info("Move to condition: " + condition); if (loggedIn()) return; logIn(); if (!loggedIn()) throw new Exception(“Can’t log In”); else logger.info(“User logedIn succesfullly"); }; public static void isLoggedIn() { logger.info("Move to condition: " + condition); if (loggedIn()) return; logIn(); if (!loggedIn()) throw new Exception(“Can’t log In”); else logger.info(“User logedIn succesfullly"); }; public static void isLoggedIn() { logger.info("Move to condition: " + condition); if (loggedIn()) return; logIn(); if (!loggedIn()) throw new Exception(“Can’t log In”); else logger.info(“User logedIn succesfullly"); }; }
  • 19. 19CONFIDENTIAL ENTITY TABLES @Data public class Entity { public String Номер; public String Тип; public String Пользователь; public String Описание; } public class Row { public Text Номер; public Dropdown Тип; public Link Пользователь; public Description Описание; }
  • 20. 20CONFIDENTIAL Row user = UsersTable.firstRow(row -> textOf(row.description).contains(“tasks”) && textOf(row.type).equals(“Admin”)); user.description.choosen.select(); ENTITY TABLES CheckboxColumn name
  • 21. 21CONFIDENTIAL ENTITY TABLES One method instead of dozens methods for each combination
  • 23. 23CONFIDENTIAL CUSTOM SCENARIOS @BeforeSuite (alwaysRun = true) public static void setUp() { ActionScenrios.actionScenario = (element, actionName, jAction, level) -> { logger.info(format("Do '%s' action", actionName)); jAction.invoke(); }; ActionScenrios.resultScenario = (element, actionName, jAction, logResult, level) -> { logger.debug(format("Do '%s' action", actionName)); Object result = jAction.get(); logger.info(format("Get '%s' action result: %s", actionName, result)); return result; }; } Like AOP
  • 24. 24CONFIDENTIAL Assert.areEquals(() -> getNext(), "IPhone 6"); Assert.contains(() -> getNext(), "IPhone 5"); WAIT ASSERT Значение станет равно X в течении таймаута
  • 25. 25CONFIDENTIAL • Incredible flexibility • Greatly reduce code amount PROS N’ CONS • Learn lambda staff • Change your and your teammates mind • Sometimes more complex debug
  • 27. 27CONFIDENTIAL public interface IForm<T> { void submit(String text, String btnName); default void login(String text) { submit(text, "login"); } default void loginAs(String text) { login(text); } default void add(String text) { submit(text, "add"); } default void publish(String text) { submit(text, "publish"); } static T ToEntity(IForm<T>) { … } static final int PAGE_NOT_FOUND = 404; … INTERFACES
  • 28. 28CONFIDENTIAL MULTI INHERITANCE public interface ITextField { void input(); void newInput(); String getValue(); } public interface ICombobox extends IDropDown, ITextField { } public interface Dropdown { void select(); void open(); } void input(); void newInput(); String getValue(); void select(); void open();
  • 30. 30CONFIDENTIAL 3 DATA CLASS public class Product { public String name; public int id; public Types type; }
  • 31. 31CONFIDENTIAL CONSTRUCTORS AND TOSTRING public Product() {} public Product(String name, int id, Types type) { this.name = name; this.id = id; this.type = type; } @Override public String toString() { return String.format("Name: %s, Id: %s, Type: %s", name, id, type); } +10
  • 32. 32CONFIDENTIAL EQUALS AND HASHCODE @Override public boolean equals(Object obj) { if (obj == null) { return false; } if (!Product.class.isAssignableFrom(obj.getClass())) { return false; } final Product other = (Product) obj; if (name == null) return other.name == null; return this.name.equals(other.name) && this.id == other.id && this.type == other.type; } @Override public int hashCode() { int hash = 3; hash = 53 * hash + (name != null ? name.hashCode() : 0); hash = 53 * hash + id; hash = 53 * hash + type.hashCode(); return hash; } +23
  • 33. 33CONFIDENTIAL @Data public class Product { public String name; public int id; public Types type; } LOMBOK 36 строк кода 1 аннотация или
  • 34. 34CONFIDENTIAL Add different Constructors Add Getters and Setters Add Builder pattern Add good ToString Add good Equals LOMBOK WARNING This can really confuse external users
  • 36. 36CONFIDENTIAL EDT: DATA DRIVEN TESTING  Provide List<User> for test
  • 37. 37CONFIDENTIAL EDT: PRECONDITIONS  Provide List<User> for test 0. Have DefaultUser in DB
  • 38. 38CONFIDENTIAL EDT: FILL AND SUBMIT  Provide List<User> for test 0. Have DefaultUser in DB 1. Login with DefaultUser
  • 39. 39CONFIDENTIAL EDT: FILL AND SEND  Provide List<User> for test 0. Have DefaultUser in DB 1. Login with DefaultUser 2. Submit Contact Us Form for DefaultUser
  • 40. 40CONFIDENTIAL EDT: EXTRACT  Provide List<User> for test 0. Have DefaultUser in DB 1. Login with DefaultUser 2. Submit Contact Us Form for DefaultUser 3. Get Act. Opening from Vacancy table
  • 41. 41CONFIDENTIAL EDT: VALIDATE  Provide List<User> for test 0. Have DefaultUser in DB 1. Login with DefaultUser 2. Submit Contact Us Form for DefaultUser 3. Get Act. Opening from Vacancy table 4. Assert Act. Opening equals to Exp. Opening ExpectedActual
  • 42. 42CONFIDENTIAL EDT & JDI DB.Users.shouldPresent(user); LoginForm.login(user); ConactUsForm.send(user); Vacancy vacancy= OpeningsTable.entity(inRow(2)); Assert.areEquals(vacancy, expectedVacancy);
  • 43. 43CONFIDENTIAL Learn language features Learn modern tools and frameworks Use popular approaches Do your work better (write tests faster, more stable, with better quality etc.) Have fun with your work! CONCLUSIONS
  • 44. 44CONFIDENTIAL • Modularity • New HTTP Client (Http2.0 & WebSocket) • Improved Process API • Language try-new, anonymous Diamond, private in interfaces, immutable set, list-optional to stream • Improved logging… JAVA 9 http://www.baeldung.com/new-java-9 27.07.2017

Editor's Notes

  1. Работаю в компании Epam в